File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes images with swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "images with swing" Watch "images with swing" New topic

images with swing

Tim Collins

Joined: May 31, 2001
Posts: 9
I am trying to insert an image into a very basic swing application. I did some research and attempted to create an ImageIcon object, using the constructor that implements a filename, then tried to add it to a JPanel. The ImageIcon is created without issue, but when I try to add it to the JPanel, I get an "unresolved symbol" error. My theory is that ImageIcon is not the right object to try to insert into the panel. Any ideas?
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

You can put ImageIcons directly onto JLabels and JButtons, but not JPanels... if you wanted to do this you would have to implement this behavior yourself...


Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Tim Collins

Joined: May 31, 2001
Posts: 9
thanks, that worked. I just initialized a JLabel with an imageicon and it worked like a charm....
I agree. Here's the link:
subject: images with swing
Similar Threads
Image or ImageIcon?
display image in jpanel
Jpcap captured packets not appearing in Swing application's text area
Mouse shift event coding - to trigger a predetermined sequence of images to a GUI
How to add images