facebook

Adding icon to JButton

  1. MyEclipse Archived
  2.  > 
  3. Matisse/Swing UI Development
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #252648 Reply

    smulgund
    Member

    My project contains Sun’s jlfgr-1.0.jar file, which contains numerous icons for buttons. Within my own code, I can add a button icon thusly:

    button.setIcon( new ImageIcon(MainWindow.class.getResource(“/toolbarButtonGraphics/general/Import24.gif” )) );

    where “MainWindow” is my subclass of JFrame containing the various widgets I need.

    How do I do the same thing from within Matisse? I tried selecting the “icon” field in the properties browser, but none of the options allow me to specify “/toolbarButtonGraphics/general/Import24.gif” as the source of the icon. Is there a project setting I need somewhere else for the GUI builder to recognize that this resource is part of the build path?

    Thanks

    Sandeep

    #252670 Reply

    Riyad Kalla
    Member

    Sandeep, this is a bug. You should be able to select JAR file contents here as a resource, I just filed this. The code in order to load from your classpath should look like this:

    
    new javax.swing.ImageIcon(getClass().getResource("/edu/arizona/econlab/edgeworth/resource/esllogonew.gif"))
    

    Sorry for the inconvenience.

    #252674 Reply

    smulgund
    Member

    Thanks for looking into this. For the moment I guess I’ll just use my own initialization code after the machine-generated method is invoked. If you can fix this bug and the issue of the disappearing palette (related to network access evidently), I’ll be a happy man!

    Sandeep

    @support-rkalla wrote:

    Sandeep, this is a bug. You should be able to select JAR file contents here as a resource, I just filed this. The code in order to load from your classpath should look like this:

    
    new javax.swing.ImageIcon(getClass().getResource("/edu/arizona/econlab/edgeworth/resource/esllogonew.gif"))
    

    Sorry for the inconvenience.

    #267057 Reply

    Claye Greene
    Member

    Does anyone know if this has been resolved yet?

    If I want to work around the issue, I’m assuming I can use the format of the code snippet to load an icon from my jar file?

    #267083 Reply

    Riyad Kalla
    Member

    Eyalc,
    I thought this had gotten fixed in 5.0 or 5.1, which version ar eyou using? Can you explain your specific use-case to me so I can test it out here?

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Adding icon to JButton

You must be logged in to post in the forum log in