Image is not fully shown in JLabel using setIcon Method
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 f开发者_开发技巧ully .. only part of image is shown in jlabel. How to solve this ?
Thanks !
Increase the size of JLabel or decrease the size of image to in JLabel.
One option is to resize the image to fit the JLabel, or increase the size of the JLabel
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
精彩评论