aspose file tools*
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
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!
 
wood burning stoves
 
subject: Creating a BufferedImage of an offscreen JButton (or other Component)