how to resize image to fit it into a jlabel
i am using a code in which i want to place my opened image in a label but only a portion of the image is being visible.
ImageIcon icon= new ImageIcon(tempfilename.getPath());
l1.setIcon(icon);
(where l1 is a label and tempfilename contains the file i am opening)
how can i resize my image in this code ?
Re: how to resize image to fit it into a jlabel
One way: create a BufferedImage of the desired size, call createGraphics() to get a Graphics2D object with which to draw on the BufferedImage, and then use one of the Graphics#drawImage(....) overloads that resizes your image for you.
Re: how to resize image to fit it into a jlabel
Moved from Advanced Java.
db