Creating a BufferedImage of an offscreen JButton (or other Component)
posted 4 years ago
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.