I want to paint the contents of a JFrame onto another frame. Currently, I only get it to work if the JFrame is visible.
Is there a way to paint a hidden JFrame?
Addi
1) you have to use proper LayoutManager, not setSize()
or setBounds()
2) if is there null LayoutManager used then Container
returns any size after setVisible(true);
3) if is there used proper LayoutManager
, then Container
return its Size
after call pack();
, in other hands this container couldn't be visible on the screen ( meaning setVisible(true);
)
4) JComponents must to returns PrefferedSize for example
Hint 1: JFrame's setDefaultLookAndFeelDecorated(false)/setUndecorated(true) might be of use for a window without caption and borders;
Hint 2: as setGlassPane/setLayeredPane/setOpaque(false) might be of use for a second "layer".
I want to get the graphical contents of a frame without having to make the frame visible for the user
The Screen Image class should help. Although I think it will only work for the "content pane" of the frame and not the entire frame (with the title bar and borders) unless you use a decorated frame.