• Post Reply Bookmark Topic Watch Topic
  • New Topic

Rescaling an ImageIcon on a button  RSS feed

 
Jack Drowder
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to write some code which rescales the icon on a button when the frame is resized. I've created a ComponentAdapter which detects when the frame is resized, and upon detection calculates the scale factor, which is stored in a variable called scaler. I then have the following code which attempts the rescale the icon:


However, when I run the program, the button itself resizes, but the icon doesn't change size, and if I reduce the size of the frame too much most of the icon gets cut off. Any suggestions for how I can fix this?

Sorry if the code snippet isn't enough - I can try making a SSCCE if there's no obvious reason why what I'm doing doesn't work.

Thanks!
 
Jack Drowder
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I've found the problem...

The icon rescales when the button is enabled, but not when it's disabled. Does anyone know a way around this?
 
Rob Camick
Ranch Hand
Posts: 2754
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try using Darryl's Stretch Icon.

The Icon will automatically change size based on the space available to the button. I haven't tried it on a disabled button, but I see no reason why it wouldn't work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!