Link to home
Start Free TrialLog in
Avatar of LarryAndro
LarryAndro

asked on

JLabel Icon Resize

I have a JPanel in which I placed a JLabel of the same size as the JPanel.  I set the icon property of the JLabel to a jpg image file.  The image file displays, but it is too large, and needs to be resized.

How do I resize the displayed (in the JLabel) icon to be the same height and width as the JLabel?

Possibly, JLabel icons cannot be resized, which would explain why I'm running into a dead end.  If so, would someone tell me the best way to display a picture in a JPanel, sized to the same size as the JPanel?

(As an aside, my IDE is Netbeans.  But, I think this is just a Java question.)
Avatar of UrosVidojevic
UrosVidojevic
Flag of Serbia image

One possible solution is to resize .jpg image with some external editor (for example Paint), and use resized image from Netbeans.
Avatar of LarryAndro
LarryAndro

ASKER

Thank you for suggestion to resize the actual image.  I can do that with a batch image editor like IrfanView.  But, since I use the image for several reasons, I would prefer to programmatically resize the image at the time of use.

Hopefully, there is a way...
ASKER CERTIFIED SOLUTION
Avatar of UrosVidojevic
UrosVidojevic
Flag of Serbia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm testing and researching these techniques.  I'll respond shortly.  Thanks for help...
Success!  Great suggestions.  (Splitting points.)  And, thank you...