Reputation: 433
Hello I am setting image to JLabel as below
ImageIcon icon=new ImageIcon(PathToImage,"Image");
jLabel4.setIcon(icon);
I have set label size as 5cm x5 cm square. Whenever i am setting icon to Jlabel it is not shown fully .. only part of image is shown in jlabel. How to solve this ?
Thanks !
Upvotes: 2
Views: 2274
Reputation: 433
I have scaled image using [java-image-scaling][1]
[1]: http://code.google.com/p/java-image-scaling/ Library.
With scaling image is very simple just need to add two lines
ResampleOp resampleOp = new ResampleOp (100,200);
BufferedImage rescaledTomato = resampleOp.filter(tomato, null);
"tomato " is name of image you want to scale. and (100,200) parameters specifies width & height of scaled image.
Thanks
Upvotes: 0
Reputation: 59650
Increase the size of JLabel or decrease the size of image to in JLabel.
Upvotes: 2
Reputation: 4546
One option is to resize the image to fit the JLabel, or increase the size of the JLabel
Upvotes: 1