This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Swing's components and Graphics2D.scale Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply 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: 157

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?
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Swing's components and Graphics2D.scale
 
Similar Threads
animation not animating...
Graphics Graphics Graphics - Where are my circles?
How to build focus rectangle
Alignment of JTextArea in OverlayLayout
Dialogs windows not displaying properly