• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Michael Cooper
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic