• Post Reply Bookmark Topic Watch Topic
  • New Topic

Scale jpanel background image

 
Esseghier Abderrahmane
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

Am new be in java and i wan to standarelize image as banner ,the image am using is big to get optimal quality,and i wan to create JPanel extended class to use it in the diffrent JFrames with this image in background.

so i must scale it i'v tried many examples but i down't know how exately i should use BufferedImage,and AffineTransform,and paintComponent.

can give an example please.



this one dosn't work
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want the image to fill the entire background then you can check out Background Panel for example code. This uses dynamic painting and does not keep the width/height aspect ratio.
 
Darryl Burke
Bartender
Posts: 5154
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... and if you're using the JPanel only to display an image (that is, you're not adding any other components to it) you can user a JLabel instead, with a StretchIcon or ShrinkIcon. You can find those classes on the site linked by Rob.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!