aspose file tools *
The moose likes Java in General and the fly likes Swing's components and Graphics2D.scale Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Swing Watch "Swing New topic
Author

Swing's components and Graphics2D.scale

Tomek Tajne
Greenhorn

Joined: Oct 05, 2011
Posts: 2
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?

Riaan Nel
Ranch Hand

Joined: Apr 23, 2009
Posts: 160

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.


"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." - George Bernard Shaw
Tomek Tajne
Greenhorn

Joined: Oct 05, 2011
Posts: 2
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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Swing's components and Graphics2D.scale