Results 1 to 3 of 3
- 07-05-2012, 03:00 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 12
- Rep Power
- 0
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.
- 07-07-2012, 07:50 AM #3
Similar Threads
-
Help: How to auto-resize the image icon to fit in the jlabel
By weikang in forum AWT / SwingReplies: 2Last Post: 11-24-2010, 02:38 PM -
How to resize images to fit JLabel?
By Krooger in forum New To JavaReplies: 3Last Post: 11-24-2010, 01:22 PM -
can't resize my JLabel
By gib65 in forum AWT / SwingReplies: 10Last Post: 06-25-2010, 05:30 AM -
how to resize an image
By marodia in forum AWT / SwingReplies: 2Last Post: 08-21-2009, 04:10 AM -
Image Resize
By jithan in forum New To JavaReplies: 4Last Post: 11-07-2008, 09:26 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks