• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

display image in jpanel

 
Dan Longest
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
they display OK for me, java 1.4.0_01
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic