且构网

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

如何在 Java 运行时将面板动态添加到其他面板?

更新时间:2023-11-30 16:49:34

我想通了.此处接受的答案下的评论对此进行了解释:动态添加的 JTable 不显示

I figured it out. The comments under the accepted answer here explain it: Dynamically added JTable not displaying

基本上我只是在 mainPanel.add() 之前添加了以下内容

Basically I just added the following before the mainPanel.add()

mainPanel.setLayout(new java.awt.BorderLayout());