Java Swing + ImageIcons
mattpotts last edited by
I've been reading wtf for a while but this is my first time posting so I hope I don't come over too stupid!
Is there any way I can dynamically resize a png image before putting it onto a JLabel?
Chris_Cudmore last edited by
It's been a while since I've done any image manipulation.
But, give this a try;
Image image = Toolkit.getDefaultToolkit().getImage(<font color="#0066ff">"image.png"</font>);
// attach observer, and make sure it's loaded.
// image.getHeight(null), getWidth(null) might be useful...
Image scaledImage= image.getScaledInstance(newHeightInPixels, newWidthInPixels, Image.SCALE_DEFAULT)
ImageIcon icon = new ImageIcon(scaledImage);