Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试创建一个扩展 JFrame 并使用 GroupLayout 的类,但我找不到如何做到这一点。JPanel 非常简单:
GroupLayout layout=new GroupLayout(this); setLayout(layout);
但是如果我使用 JFrame,它会说我在第二行为框架添加了两个容器,但没有该行,则不添加布局,显示最后添加的组件。尝试谷歌搜索,没有运气。谢谢!
对于GroupLayout主机容器,您需要使用将所有可见组件添加到JFrame. 这是ContentPane:
GroupLayout
JFrame
ContentPane
JFrame frame = new JFrame(); GroupLayout groupLayout = new GroupLayout(frame.getContentPane()); frame.setLayout(groupLayout);