If I set a layout on a JFrame
with setLayout
and then retrieve it with getLayout
then I get a different LayoutManager
. What is going on here??
public class Lay {
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
java.awt.Container container =
new javax.swing.JFrame();
//new javax.swing.JPanel();
java.awt.LayoutManager layout =
new java.awt.GridLayout();
container.setLayout(layout);
layout = container.getLayout();
System.err.println(layout);
}
});
}
}
Gives
java.awt.BorderLayout[hgap=0,vgap=0]
but if I replace JFrame
with JPanel
I get
java.awt.GridLayout[hgap=0,vgap=0,rows=1,cols=0]