想知道 JFrames (BorderLayout) 的区别
Want to know difference in JFrames (BorderLayout)
我想知道有什么区别:
window.getContentPane().setLayout(new BorderLayout());
和
window.setLayout(new BorderLayout());
(window 是一个 JFrame 对象)。
感谢您的肯定回答。
检查 Java 文档...
http://docs.oracle.com/javase/7/docs/api/javax/swing/JFrame.html
"The JFrame class is slightly incompatible with Frame. Like all other JFC/Swing top-level containers, a JFrame contains a JRootPane as its only child. The content pane provided by the root pane should, as a rule, contain all the non-menu components displayed by the JFrame. This is different from the AWT Frame case. As a conveniance add and its variants, remove and setLayout have been overridden to forward to the contentPane as necessary."
使用 getContentPane()
我总是创建一个新的 JPanel 对象并调用 setContentPane()
将其添加到 JFrame 对象中
我想知道有什么区别:
window.getContentPane().setLayout(new BorderLayout());
和
window.setLayout(new BorderLayout());
(window 是一个 JFrame 对象)。
感谢您的肯定回答。
检查 Java 文档...
http://docs.oracle.com/javase/7/docs/api/javax/swing/JFrame.html
"The JFrame class is slightly incompatible with Frame. Like all other JFC/Swing top-level containers, a JFrame contains a JRootPane as its only child. The content pane provided by the root pane should, as a rule, contain all the non-menu components displayed by the JFrame. This is different from the AWT Frame case. As a conveniance add and its variants, remove and setLayout have been overridden to forward to the contentPane as necessary."
使用 getContentPane()
我总是创建一个新的 JPanel 对象并调用 setContentPane()
将其添加到 JFrame 对象中