This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes jpeg in a Jpanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "jpeg in a Jpanel" Watch "jpeg in a Jpanel" New topic
Author

jpeg in a Jpanel

Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
Hi folks,
I need to display a jpeg on a JPanel. I need it as a background, no other components will be on this JPanel. I have tried to set the jpeg as the icon for a JLabel that takes the entire size of JPanel but the dimensions of the jpeg are too small. I need the jpeg to take up the entire JPanel no matter what the screen resolution is set to.
Could someone give the code on how to do this or at least point me in the right direction?
Thanks!!


Jason R. Kretzer<br />Software Engineer<br />System Administrator<br /><a href="http://alia.iwarp.com" target="_blank" rel="nofollow">http://alia.iwarp.com</a>
Angela Lamb
Ranch Hand

Joined: Feb 22, 2001
Posts: 156
I think this should work for you:

You can look at the API for Image to see more options for the getScaledInstance method. I used the SCALE_SMOOTH property in this example, but there are other options that use different scaling algorithms.
Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
Thank you very much. It worked like a charm!

Jason
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jpeg in a Jpanel
 
Similar Threads
Image as a background
JAI, Image CMYK to RGB
Executable jar - including image files
setting image as a background
JPanel Background Colour