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
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 Pelagalli
Ranch Hand

Joined: Nov 11, 2003
Posts: 150
    
    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 Pelagalli
Ranch Hand

Joined: Nov 11, 2003
Posts: 150
    
    1
Thank you Craig!
That is exactly what I needed!
Lou
 
 
subject: JButton with ImageIcon Size Problem