Results 1 to 3 of 3
- 07-05-2012, 03:00 PM #1Member
- Join Date
- Jul 2011
- Rep Power
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());
(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.
- 07-07-2012, 07:50 AM #3
- By weikang in forum AWT / SwingReplies: 2Last Post: 11-24-2010, 03:38 PM
- By Krooger in forum New To JavaReplies: 3Last Post: 11-24-2010, 02:22 PM
- By gib65 in forum AWT / SwingReplies: 10Last Post: 06-25-2010, 05:30 AM
- By marodia in forum AWT / SwingReplies: 2Last Post: 08-21-2009, 04:10 AM
- By jithan in forum New To JavaReplies: 4Last Post: 11-07-2008, 10:26 AM