File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes display image in jpanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "display image in jpanel" Watch "display image in jpanel" New topic
Author

display image in jpanel

Dan Longest
Greenhorn

Joined: Apr 28, 2005
Posts: 5
I want to display an image using swing. How do I add the image to a jpanel or jframe? I've tried finding a way to do it with Image and ImageIcon with no success. A link to the right information would be fine.

Dan


"If I want a group decision I'll look in a mirror" - Warren Buffett
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
here's a post from a couple of days ago, with a link to the FAQ on this,
also with query re missing call - include the line
super.paintComponent(g);
as the first line in paintComponent()

http://www.coderanch.com/t/341258/GUI/java/FAQ-BackgroundImageOnJPanel-missing-call-super

edit:
perhaps you just need to use a JLabel, which takes an icon as a parameter
[ August 14, 2005: Message edited by: Michael Dunn ]
Russell Ray
Ranch Hand

Joined: Apr 25, 2005
Posts: 116
First of all, I am am very new in using Swing components and I am learning under fire. You recommedation works for 1.4 JDK. Is there a different way for JDK 1.3? I am having a similar problem with the same subject, but in JDK 1.3. I do not have the ImageIO class available to me. My problem is simple, the images are not displaying.



Thanks for any suggestions.

Russ
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
they display OK for me, java 1.4.0_01
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: display image in jpanel