This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

display image in jpanel

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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()

https://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 ]
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
they display OK for me, java 1.4.0_01
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic