• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Rescaling an ImageIcon on a button

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic