• 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

Image that Fits

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello ranchers....

I am using an Image inside the Panel and dialog box. when the image is loaded it doesnt fit to that panel, it seems like the image is gone half way. so my doubt is how to fit an image inside a panel or dialog box? even if i resize the frame or dialog box, the image must adjust according to its dimension....
plz help me out....

Thank you
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
create a sub-classed JPanel, overriding paintComponent(Graphics g).
in paintComponent you use g.drawImage(x,y,w,h,this) where
x,y are usually 0,0
w,h are width,height

do not 'get' (or load) the image inside paintComponent
 
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"madhu cm",

Please review the JavaRanch Naming Policy and modify your display name. You can do that here.
 
reply
    Bookmark Topic Watch Topic
  • New Topic