This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Creating a BufferedImage of an offscreen JButton (or other Component) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Creating a BufferedImage of an offscreen JButton (or other Component)" Watch "Creating a BufferedImage of an offscreen JButton (or other Component)" New topic
Author

Creating a BufferedImage of an offscreen JButton (or other Component)

Michael Cooper
Greenhorn

Joined: Jul 29, 2012
Posts: 1
I am trying to create a Swing component that, in its paint() method, draws a possibly scaled version of JButtons and other Components. It would not be appropriate to physically place those Components inside the original Component because the layout managers would not do the type of "scaling" I am looking for - I would like the text/image inside to also be scaled.

What I am getting are empty gray boxes of the appropriate sizes. If I use JButtons I don't see the the rounded corners or the button text, and if I use a JPanel with a JLabel within I don't see the label's text. The problem appears to be with my use of the Component.createImage() function, but I can't figure out why.

Here's the basic code:



Thank you so much for any help!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating a BufferedImage of an offscreen JButton (or other Component)
 
Similar Threads
how to streach an image all over the button
Image problem
Reduce size of image
problem with JPanel / JLabel zooming
Adjusting image size to image label