How do I add an image file to a library?

Hi,
My project requires files (normally in the form of JPEGs and PDFs) to be added to a library. The file paths are passed into the plug-in via sockets.
In QuarkXPress we do this by using a hidden document, which is not visible or accessible by the user. Files are placed on the document and then transferred into the library. I can see how to do some of this in InDesign:
Create a library using - ILibraryCmdUtils::CreateLibraryNewLibCmd()
Add an item - ILibraryCmdUtils::CreateLibraryAddItemCmd()
The bit I can't work out is the hidden document. I was hoping that a document could be created as hidden via the INewDocCmdData interface - no joy. I cannot see any reference to hidden documents anywhere in the SDK documentation. Does InDesign have a default one? So I'm wondering if this is the best way to do it.
Can anybody point me in the right direction? It might be that hidden documents is not the best approach.
Best regards and thanks in advance.

Thanks to Dirk's help, I've now got my library code up and running. I can now handle my library through commands from an external source and from any user action. Had a few problems with outstanding bosses, but I've managed to configure the code to prevent this.
With that out the way my attention has moved back to adding image files to the library via a hidden/headless document. I've written some code that will transfer images from the document to the library using ILibraryCmdUtils::ProcessLibraryAddItemCmd().
The bit that's giving me problems is the file to document bit. The SDKHelper sample code (function PlaceFileInFrame) shows how this can be done, but there is a snag - I don't want the user to see the document that is used to transfer files to the library. Unfortunately a document UIDRef will not work in IHierarchy as it is not a displayable item.
Does anyone know of a way this can be done? The user should not see or interact with the document.
Cheers,
APMABC

Similar Messages

  • How do I add shared music files to my library?

    Hi I have music sharing on and I can play all of the songs on this PC that are shared from my laptop, but is there a way to copy and add all of the actual music files onto my PC? Or can I just stream them with home sharing and need to use an external drive or some other way to get the actual files on this PC.
    Using up to date iTunes 12 on both PC and laptop.

    Hi ajoddo20,
    Welcome to the Apple Support Communities!
    You can use Home Sharing to import music and other media from one computer to another. Please use the instructions and information located in the attached article for information on how to complete the process. 
    iTunes 11 for Mac: Use Home Sharing to import items from another iTunes library
    Cheers,
    Joe 

  • How do I add MPEG-4 files to my library?!

    I've been able to simply drag videos into my library in previous versions of iTunes but now I can't import them at all. I can't drag them, I can't go add file to library, I can't make a new folder inside my iTunes content and copy the file over. Starting to seriously frustrate me now. Someone help

    Hi ajoddo20,
    Welcome to the Apple Support Communities!
    You can use Home Sharing to import music and other media from one computer to another. Please use the instructions and information located in the attached article for information on how to complete the process. 
    iTunes 11 for Mac: Use Home Sharing to import items from another iTunes library
    Cheers,
    Joe 

  • How can add a images file  to anothere image file

    hi
    Requirement is: i have one image in data base , i is show to user in my application
    know we want add another image file in to a current image file (just append)
    at end .
    i was tried with following code below
    i was read the previous(Old) image content from the data base and placed into c:\\ReArchive\\test_content.tiff
    ResultSet rs2=dbBean.getSQLRows("select binarycontent from ContentVersion where contentindex="+IndexValue+"");
    byte[] bTempData_content=new byte[65536];
    while(rs2.next()){              
    File f = new File("c:\\ReArchive\\test_content.tiff");
    f_content.delete();
    f_content.createNewFile();
    FileOutputStream dest_contentVersion = new FileOutputStream(f_content);
    while(rs2.next()){              
    InputStream is_content=rs2.getBinaryStream("Binarycontent");
    nActualRead_content=is.read(bTempData_content,0,65536);
    while(nActualRead_content>0)
    dest_contentVersion.write(bTempData_content,0,nActualRead_content);
    nActualRead_content=is.read(bTempData_content,0,65536);
    Then i was took New image file from data base and place in to c:\\ReArchive\\test.tiff");
    int nActualRead=0;
    ResultSet rs1=dbBean.getSQLRows("select * from Object_Store where Barcode_ID='"+strBar_Code+"'");
    byte[] bTempData=new byte[65536];
    File f = new File("c:\\ReArchive\\test.tiff");
    f.delete();
    f.createNewFile();
    FileOutputStream dest = new FileOutputStream(f);
    while(rs1.next()){
    InputStream is=rs1.getBinaryStream("Obj_Content");
    nActualRead=is.read(bTempData,0,65536);
    while(nActualRead>0)
    dest.write(bTempData,0,nActualRead);
    nActualRead=is.read(bTempData,0,65536);
    then i tried add two images by converting InputStream to String and i am trying add to images
    but i was failed ,i think i am in not correct way , how can i solve this problem
    thanks advance
    gss

    Don't you think it would be a good idea to tell us how you failed?

  • How to add an image file to Oracle db?

    Need help urgently....Anybody knows how to add an image file (example: jpg)into one of the fields in Oracle database??

    This will do the job..
    package forum;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    //import oracle.sql.*;
    Wanneer een request.getInputStream wordt geconferteerd naar een "String" (zie later) dan ziet de output in tekstformaat er als volgt uit:
    -----------------------------7d280152604f4 Content-Disposition: form-data; name="oploadfile"; filename="C:\WINNT\Profiles\mvo\Desktop\boodschap.txt" Content-Type: text/plain Deze boodschap dient te worden ge-insert in de database. -----------------------------7d280152604f4 Content-Disposition: form-data; name="StadID" 1234 -----------------------------7d280152604f4 Content-Disposition: form-data; name="SuccessPage" /forum/error.jsp -----------------------------7d280152604f4--
    of opgesplitst
    contentType........... multipart/form-data; boundary=---------------------------7d235ade00f0
    filename.............. "C:\Documents and Settings\Administrator\Desktop\boodschap.txt"
    MIME type............. text/plain
    Wat in database moet.. Dit is de eigenlijke boodschap die moet worden ge-insert in de database.
    Eind boundary......... -----------------------------7d235ade00f0 Content-Disposition: form-data; name="file1"; filename="" Content-Type: application/octet-stream -----------------------------7d235ade00f0--
    We gaan achtereenvolgens:
    1. Kijken of het van het "multipart/form-data" type is (uploaden) en strippen van eerste boundery.
    1.a Geen "multipart/form-data" ? dan... error message
    1.b Groter dan MAX_SIZE ?..dan .. error message
    2. Filenaam van de te uploaden file uitlezen
    3. Mimetype bepalen en bepalen in welke positie van de string het Mimetype ophoudt, cq waar te uploaden file begint
    4. Bepalen waar eind boundery begint
    5. De eigenlijke file uitlezen
    6. Terug converteren naar bytes
    public class WriteBlob extends HttpServlet {
    public static final int MAX_SIZE = ParameterSettings.imageUpload;
    String successMessage = "";
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    * Process the HTTP Get request
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    DataInputStream in = null;
    FileOutputStream fileOut= null;
    PrintWriter out = response.getWriter();
    int kb_size = 0;
    boolean pass2 = true;
    String message = "";
    String responseRedirect = "/forum/uploaden.jsp?message="+" Uploaden geslaagd";
    try
    //get content type of client request
    String contentType = request.getContentType();
    // Start stap 1...content type is multipart/form-data
    if(contentType != null && contentType.indexOf("multipart/form-data") != -1)
    //open input stream
    in = new DataInputStream(request.getInputStream());
    //get length of content data
    int formDataLength = request.getContentLength(); // totale lengte van de inputstream
    //initieer een byte array om content data op te slaan
    byte dataBytes[] = new byte[formDataLength];
    //read file into byte array
    int bytesRead = 0;
    int totalBytesRead = 0;
    int sizeCheck = 0;
    while (totalBytesRead < formDataLength)
    //kijken of de file niet te groot is
    sizeCheck = totalBytesRead + in.available();
    if (sizeCheck > MAX_SIZE)
    pass2 = false;
    message = "Sorry. U kunt slechts bestanden uploaden tot een grootte van 500KB";
    responseRedirect = "/forum/uploaden.jsp?message="+message;
    bytesRead = in.read(dataBytes, totalBytesRead,formDataLength);
    totalBytesRead += bytesRead;
    if (pass2==true)
    kb_size = (int)(formDataLength/1024);
    //create string from byte array for easy manipulation
    String file = new String(dataBytes);
    /*get boundary value (boundary is a unique string that separates content data)
    contentType........... multipart/form-data; boundary=---------------------------7d235ade00f0
    int lastIndex = contentType.lastIndexOf("=");
    String boundary = contentType.substring(lastIndex+1, contentType.length());
    // Stap 2.....bepaal de naam van de upload file
    // filename.............. "C:\Documents and Settings\Administrator\Desktop\boodschap.txt"
    String saveFile = file.substring(file.indexOf("filename=\"")+10);
    saveFile = saveFile.substring(0,saveFile.indexOf("\n"));
    saveFile = saveFile.substring(saveFile.lastIndexOf("\\")+1,saveFile.indexOf("\"")); //naam van de file...boodschap.txt
    String saveFileName = saveFile;
    // Stap 3..Bepaal MIME Type en de positie van eind mime type in string
    voorbeeld: -----------------------------7d23d21220524 Content-Disposition: form-data; name="file0"; filename="C:\WINNT\Profiles\mvo\Desktop\z clob.txt" Content-Type: text/plain
    String restant = "";
    int pos; //position in upload file
    // bijv .. filename="C:\Documents and Settings\Administrator\Desktop\boodschap.txt"
    pos = file.indexOf("filename=\"");
    //find position of content-disposition line
    pos = file.indexOf("\n",pos)+1; // eing file naam + spatie
    // onderstaand geeft bijv Content-Type: text/plain
    restant = file.substring(pos,file.indexOf("\n",pos)-1);
    restant = restant.substring(restant.indexOf(":")+2,restant.length()); // MIME type
    String mimeType = restant;
    //find position of eind content-type line
    pos = file.indexOf("\n",pos)+1;
    //find position of blank line
    pos = file.indexOf("\n",pos)+1;
    int start = pos;
    // Stap 4 eind boundary
    /*find the location of the next boundary marker (marking the end of the upload file data)*/
    int boundaryLocation = file.indexOf(boundary,pos)-4; //waarom -4 ..? ziet er uit als linebreak spatie--boundary=-----------------------------7d21c9ae00f0
    // Stap 5 en 6..de eigelijke te uploaden file in nieuwe byte file inserten
    byte dataBytes2[] = new byte[boundaryLocation-start]; //declareren
    for (int i=0;i<(boundaryLocation-start);i++) // inserten BELANGRIJK !!
    dataBytes2=dataBytes[start+i];
    String next_id = "0";
    Statement statement = null;
    Connection conn = null;
    boolean pass = true;
    ResultSet rs = null;
    Statement stmt_empty = null;
    oracle.sql.BLOB blb = null;
    try
    int vendor = DriverUtilities.ORACLE;
    String username = ConnectionParams.userName;
    String password = ConnectionParams.passWord;
    String connStr = DriverUtilities.makeURL(vendor);
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    conn = DriverManager.getConnection(connStr,username, password);
    if (conn==null){pass=false;}
    } catch (Exception e){out.println("<P>" + "There was an error establishing a connection:");}
    if (pass==true)
    try
    String seq_nextval ="select forum_blob_seq.nextval from dual";
    statement = conn.createStatement();
    ResultSet rset = statement.executeQuery(seq_nextval);
    while (rset.next())
    next_id = rset.getString(1);
    if (next_id.equals("0"))
    message = "Uploaden mislukt !...Er ging wat fout tijdens de interactie met de database";
    responseRedirect = "/forum/uploaden.jsp?message="+message;
    pass = false;
    } catch (Exception e1) { out.println("Error blob1 : "+e1.toString()); };
    } // end pass
    if (pass==true)
    try
    Statement stmt2 = conn.createStatement();
    String insert_empty_blob = "INSERT INTO test_blob(id "+
    ",filename "+
    ",mimetype "+
    ",kb) "+
    "VALUES("+Integer.parseInt(next_id) +
    ",'"+saveFileName+"'"+
    ",'"+mimeType+"'"+
    ","+kb_size+")";
    stmt2.executeQuery(insert_empty_blob);
    conn.commit();
    if (stmt2!= null) {stmt2.close();}else{stmt2.close();pass = false;}
    } catch (Exception e2){
    message = "Uploaden mislukt !...Er ging wat fout tijdens de interactie met de database";
    responseRedirect = "/forum/uploaden.jsp?message="+message;
    out.println("<P>" + "2. There was an error inserting mime type:");}
    } //end pass
    if (pass==true)
    try
    conn.setAutoCommit(false);
    } catch (Exception e3) { pass = false; out.println("Error blob 3: "+e3.toString()); };
    } //end pass
    if (pass==true)
    try
    String Query_blob ="Select test_blob FROM test_blob where id="+next_id+" FOR UPDATE";
    stmt_empty = conn.createStatement();
    rs=stmt_empty.executeQuery(Query_blob);
    } catch (Exception e4) {
    pass = false;
    out.println("Error blob 4: "+e4.toString());
    message = "Uploaden mislukt !...Er ging wat fout tijdens de interactie met de database";
    responseRedirect = "/forum/uploaden.jsp?message="+message;};
    } //end pass
    if (pass==true)
    try
                             if (rs.next())
                             blb = ((OracleResultSet)rs).getBLOB(1);
                        OutputStream stmBlobStream = blb.getBinaryOutputStream();
                             try {
                                  int iSize = blb.getBufferSize();
                             byte[] byBuffer = new byte[iSize];
                             int iLength = -1;
    ByteArrayInputStream stmByteIn = new ByteArrayInputStream(dataBytes2);
                                  try {
    // while ( (iLength = in.read(byBuffer, 0,      iSize)) != -1 )
    while ( (iLength = stmByteIn.read(byBuffer, 0,      iSize)) != -1 )
                                       stmBlobStream.write(byBuffer, 0, iLength);
                                       stmBlobStream.flush();
                                       } // end while
    } catch (Exception e5) {
    pass=false;
    out.println("Error blob 5: "+e5.toString());
    message = "Uploaden mislukt !...Er ging wat fout tijdens de interactie met de database";
    responseRedirect = "/forum/uploaden.jsp?message="+message; }
                                  finally { conn.commit();     }
    } catch (Exception e6) { out.println("Error blob 6: "+e6.toString()); };
                             } //end if rs.next()
                             else {      throw new SQLException("Could not locate message record in database."); }
    } catch (Exception e7) { out.println("Error blob : "+e7.toString()); };
    } // end pass
    } // end pass2
    else //request is not multipart/form-data
    message = "Uploaden mislukt !...Gegevens niet verstuurd via multipart/form-data.";
    responseRedirect = "/forum/error.jsp?message="+message;
    out.println("Request not multipart/form-data.");
    catch(Exception e)
    try
    //print error message to standard out
    out.println("Error in doPost: " + e);
    //send error message to client
    out.println("An unexpected error has occurred.");
    out.println("Error description: " + e);
    }catch (Exception f) {}
    response.sendRedirect(responseRedirect);
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    doPost(request,response);
    Regards
    Martin

  • How to i add an image path with spry data set

    hi
    how to i add an image path with spry data set. I made a xml file and then created a data set in html but image won't load
    this is my XML
    <?xml version="1.0" encoding="UTF-8"?>
    <banner width = "185" height = "400">
        <item>
            <image scr = "nui-panforte-recipe_01.jpg" ></image>
            <description>CHOC-COCONUT PANFORTE</description>      
            <text1>Try this delicious GLUTEN FREE Christmas treat</text1>
            <text2>CHOC-COCONUT PANFORTE</text2>
        </item>
    </banner>
    this is my HTML
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:spry="http://ns.adobe.com/spry">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script src="../../SpryAssets/xpath.js" type="text/javascript"></script>
    <script src="../../SpryAssets/SpryData.js" type="text/javascript"></script>
    <script type="text/javascript">
    <!--
    var ds1 = new Spry.Data.XMLDataSet("recipe_banner.xml", "banner/item");
    //-->
    </script>
    </head>
    <body>
    <div spry:region="ds1">
      <table>
        <tr spry:repeat="ds1">
          <td>{image}</td>
          <td>{description}</td>
          <td>{text1}</td>
          <td>{text2}</td>
          <td>{text3}</td>
          <td>{text4}</td>
          <td>{link}</td>
          <td>{url}</td>
          <td>{target}</td>
        </tr>
      </table>
    </div>
    </body>
    </html>

    It would be helpfull if you actually created an <img> tag to start with
    <img src="{image/@src}" />
    would work.

  • My itunes stops working when i try to add a music file to the library. how do i fix this?

    when I open iTunes and try to add a music file to my library from my computer, I slecet the song and click open and then it just comes up with the error message saying that iTunes has stopped woking and closes the program... ive tried everything- uninstalling and reinstalling the program and even disabling my antivirus software. I have no other ideas about how to fix this?

    If you are still having this problem, the fix below takes care of it.  It was posted in another conversation by Sony Singh. I did it, rebooted, and all works!!
    Copy QTMovieWin.dll from:  C:\Program Files (x86)\Common Files\Apple\Apple Application Support
    to: C:\Program Files (x86)\iTunes
    Hope this helps or you've already done the fix, especially since you posted in October.

  • How do I add an existing file to a project?

    To add an existing files to a project in JDeveloper 9.0.5.2 I use File/Import and select "Existing Sources". In Jdeveloper 10.1.3.0.2 the "Existing Sources" option was substituted by "Create Project from Existing Source". The documentation topic in 10.1.3 “Adding Existing Files to an Existing Project Using the Add Files or Directories Dialog” indicates File/Open and use a “Add Files or Directories dialog” that I can not find.
    How do I add an existing file to a project?

    To add an existing files to a project in JDeveloper
    9.0.5.2 I use File/Import and select "Existing
    Sources". In Jdeveloper 10.1.3.0.2 the "Existing
    Sources" option was substituted by "Create Project
    from Existing Source". The documentation topic in
    10.1.3 “Adding Existing Files to an Existing
    Project Using the Add Files or Directories Dialog”
    indicates File/Open and use a “Add Files or
    Directories dialog” that I can not find.
    How do I add an existing file to a project?Right now you just need to copy the file into the sourcepath of your project, going forward we're going to provide some easier way to do this.
    i.e. you can use the windows explorer to copy C:\src\com\acme\MyClass.java to C:\jdev\mywork\Application1\Project1\src\com\acme\MyClass.java
    Hope this helps,
    Rob
    Team JDev

  • How do I add an image to my navigation bar?

    How do I add an image to my navigation bar? I created my own. Let's say for example I wanted to a page dedicated to the lakers rss feed, and instead of having text in the box "Lakers", I want it to be the lakers logo. I already have the hyperlink in that box working.

    That didn't sound right:
    How do I add an image to my navigation bar? I created my own. Let's say for example I wanted to have a page dedicated to the lakers rss feed, and instead of having text in the box on the bar that reads "Lakers", I want it to be the lakers logo. I already have the hyperlink in that box that will direct you to that page.

  • How do I add a log file to posts? (NT)

    How do I add a log file to posts?
    Thanks,

    here is the output of copy/paste:
    I [17/Oct/2007:05:51:44 -0500] Configured for up to 100 clients.
    I [17/Oct/2007:05:51:44 -0500] Allowing up to 100 client connections per host.
    I [17/Oct/2007:05:51:44 -0500] Using policy "default" as the default!
    I [17/Oct/2007:05:51:44 -0500] Full reload is required.
    I [17/Oct/2007:05:51:45 -0500] Loaded MIME database from '/etc/cups': 35 types, 40 filters...
    I [17/Oct/2007:05:51:46 -0500] Loading job cache file "/var/cache/cups/job.cache"...
    I [17/Oct/2007:05:51:46 -0500] Full reload complete.
    I [17/Oct/2007:05:51:46 -0500] Listening to :::631 on fd 2...
    I [17/Oct/2007:05:51:46 -0500] Listening to 0.0.0.0:631 on fd 3...
    I [17/Oct/2007:05:51:46 -0500] Listening to /var/run/cups/cups.sock on fd 4...
    (The strikethrough is one of the many bugs in the Forum software...)
    Use Console Utility to show you the log files, if that is what you need to know.

  • How can I add an audio file to each slide when I export to HTML Keynote 6.2

    How can I add an audio file to each slide when I export to HTML Keynote 6.2
    I am trying to create an audio slide show instead of a movie

    Drag and drop one music files onto each slide then export. (File > Export > HTML)

  • How can I add an image to a dowload, specialy if I bougth from I tunes?

    Hello
    How can I add an image to a dowload, specialy if I bougth from I tunes?

    That is not quite right. The image must be in a directory that is under the web server's view. JSP has nothing to do with images, the browser loads images separately after parsing the HTML results to find out what images it has to load. The images must be in a place that is servable by the web server being used.
    If you were just using Tomcat as a web server, then you would have a web application directory "myapp". The images need to go under "myapp" or in any subdirectory, except the WEB-INF directory, which is a special case.

  • How do I add an image specified by a URL to an application?

    I am building a Java FAQ page for my college and I am stumped by this question: How do I add an image specified by a URL to an application?
    I am trying to do something like this:
    try {
    ImageIcon logoImage = new ImageIcon(new URL("http://www.gcodes.net/tutor/javafaq/Java%201130%20FAQ/images/comments.png"));
    } //end try
    catch(MalformedURLException e) {
    }//end catch
    //add image to JLabel
    topLogoHolder.setIcon(logoImage);I've looked through my Java textbooks and done many google searches. Please help.
    -Matt

    Are you having problems with logoImage being undefined?
    Because, as you have it, logoImage only exists within the 'try' block.
    Either call topLogoHolder.setIcon(logoImage) within the 'try' block, or declare the logoImage outside the 'try' block and set it within the 'try' block.
    I'd say you might as well call setIcon within the 'try' block, if you don't need the logoImage value elsewhere. Because, if you get that exception that you are catching, your ImageIcon won't be initialized right, anyway.

  • How do you add an image in the signature

    Hi,
    How do you add an image to the signature area.
    The Insert/edit image is not available when in My Settings | Personnel Info | Signature
    Regards
    Ray Farmer

    You need to link the image.  See the example for the Canada flag below.
    <img src="http://forums.ni.com/ni/attachments/ni/130/6908/1/Canada-small.PNG" border=0>
    Replace with the image you like.  This goes into the signature box within the profile tab of the personal settings.
    RayR

  • How do i add an image in my Grid Layout

    I want to add an image form my directory on to a grid. I do not want to add a button, because that is all i seem to be seeing online. I just simply want to add a image from my directory into my grid.
    setLayout(new GridLayout(3,2));
    .......How do i add my image.
    image is called picture.jpg
    Thankyou
    Hemant

    Take a look to this code :
    You can make a pane component in which an image is displayed
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.border.Border;
    * Pane which displays an image.
    * @author     Antoine Lemoine
    * @version     1.0 (Released November 26, 2005)
    public class ImagePane extends JPanel
                   Constructors
         public ImagePane(ImageIcon imageIcon)
              setOpaque(false);
              setImage(imageIcon);
              this.autoSize = false;
              this.conserveProportions = false;
              this.minimizeOnly = false;
         public ImagePane(String imageFile)
              this(new ImageIcon(ClassLoader.getSystemResource(imageFile)));
         public ImagePane(String imageFile, Color background, Dimension dimension)
              this(imageFile);
              setBackground(background);
              setPreferredSize(dimension);
                   Protected redefined methods
         protected void paintComponent(Graphics g)
              super.paintComponent(g);
              int w = imageIcon.getIconWidth();
              int h = imageIcon.getIconHeight();
              Insets margin = getInsets();
              if (autoSize)
                   ((Graphics2D)g).setRenderingHint(
                        RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);
                   int w2 = getWidth();
                   int h2 = getHeight();
                   if (conserveProportions)
                        if (w2/w>h2/h) { w2 = h2*w/h; }
                        else { h2 = w2*h/w; }
                   if (!minimizeOnly || w2<w)
                        w = w2;
                        h = h2;
              g.drawImage(imageIcon.getImage(),margin.left,margin.top,w,h,this);
                   Public methods
         public void setImage(ImageIcon imageIcon)
              Insets margin = getInsets();
              if (imageIcon!=null);
                   this.imageIcon = imageIcon;
                   setPreferredSize(
                        new Dimension(
                             imageIcon.getIconWidth()+margin.left+margin.right,
                             imageIcon.getIconHeight()+margin.top+margin.bottom));
         public void setBorder(Border border)
              super.setBorder(border);
              Insets margin = getInsets();
              int w = (imageIcon!=null ? imageIcon.getIconWidth() : 0);
              int h = (imageIcon!=null ? imageIcon.getIconHeight() : 0);
              setPreferredSize(
                   new Dimension(w+margin.left+margin.right,h+margin.top+margin.bottom));
         public void setMinimizeOnly(boolean minimizeOnly)
              this.minimizeOnly = minimizeOnly;
         public void setAutoSize(boolean autoSize)
              this.autoSize = autoSize;
         public void setConserveProportions(boolean conserveProportions)
              this.conserveProportions = conserveProportions;
                   Private attributes
         private ImageIcon imageIcon;
         private boolean autoSize;
         private boolean minimizeOnly;
         private boolean conserveProportions;
    }

Maybe you are looking for