• Post Reply Bookmark Topic Watch Topic
  • New Topic

Image that Fits  RSS feed

 
madhu cm
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • 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
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • 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
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"madhu cm",

Please review the JavaRanch Naming Policy and modify your display name. You can do that here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!