且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在调整Jframe大小之前,JPanel不会更新

更新时间:2023-12-05 18:28:58

验证在添加组件并调用 setVisible() /javase/7/docs/api/java/awt/Window.html#pack%28%29\"rel =nofollow noreferrer> pack() ,如本相关示例中所述。您可能还需要采用适当的布局。按照此处的建议调用 repaint()可能会修复症状但不是根本原因。

Verify that you invoke setVisible() after adding components and calling pack(), as discussed in this related example. You may also need to adopt an appropriate layout. Invoking repaint(), as suggested here, may fix the symptom but not the underlying cause.