• 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

Swing's components and Graphics2D.scale

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have image and Swing components in my panel and I'm trying to resizing it by using Graphics2D.scale(int, int), but Swing's component aren't looking properly after that.
See what's happen with JButton and JLabel after using Graphics2D.scale.
How can I fix it?

 
Ranch Hand
Posts: 160
IntelliJ IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why don't you just call setPreferredSize() on your components? That is the more 'correct' way of doing it. Generally you shouldn't be messing with the way in which Swing components are painted.

 
Tomek Tajne
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Riaan Nel wrote:Why don't you just call setPreferredSize() on your components? That is the more 'correct' way of doing it. Generally you shouldn't be messing with the way in which Swing components are painted.


I'm trying to resize view of whale panel with a big image and many Swing Components. There is no image in the code I've pasted above, but there is a rectangle instead.
I need buttons with zoom in/zoom out options, and I though that using Graphics2D.scale would be the best option, because Image.getScaledInstance takes too much time:(
Do you know how to fix this code?
 
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic