aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JButton with ImageIcon Size Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JButton with ImageIcon Size Problem" Watch "JButton with ImageIcon Size Problem" New topic
Author

JButton with ImageIcon Size Problem

Lou Pellegrini
Ranch Hand

Joined: Nov 11, 2003
Posts: 142
    
    1
Hi,
I have a JButton with an ImageIcon showing just fine.
I need to be able to resize the button and of course its icon, but when the button gets to small the icon disappears.
Is there a way I can dynamically change the size of the icon to fit the JButton? Or am I stuck making several icon files?
Thank You in Advance for Your Help,
Lou
KR Campbell
Ranch Hand

Joined: Mar 26, 2004
Posts: 124
Hi,
If you are using an ImageIcon then it has a getScaledInstance() method. I seem to remember using this for something similar once.
Regards,
Ken
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Lou Pellegrini
Ranch Hand

Joined: Nov 11, 2003
Posts: 142
    
    1
Thank you Craig!
That is exactly what I needed!
Lou
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JButton with ImageIcon Size Problem
 
Similar Threads
Problems with Image Icons in Forte 3.0
Icons
How to set .ico - files as icons in an Applet?
Image as a button
jbutton background image