How to paint an invisible JFrame elsewhere?

后端 未结 3 1259
無奈伤痛
無奈伤痛 2021-01-23 14:57

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

3条回答
  •  北海茫月
    2021-01-23 15:09

    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

提交回复
热议问题