Force immediate layout and paint in Swing

后端 未结 3 940
北恋
北恋 2020-12-19 09:54

I cannot seem to force a layout in Swing. I have a JComponent added to a JLayeredPane and I set a border on the JComponent. Then, I wa

3条回答
  •  长情又很酷
    2020-12-19 10:19

    This is super old, but I found a simple solution, which I'll show with a JPasswordField:

    var pw = new JPasswordField();
    ...
    pw.paint(pw.getGraphics()); // paints immediately
    

提交回复
热议问题