• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jpeg in a Jpanel

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much. It worked like a charm!

Jason
 
reply
    Bookmark Topic Watch Topic
  • New Topic