07 October 2002 - java_dev (original) (raw)
greetings,
i'm using swing and trying to create a main panel that contains ONE main row, and within that main row, it should contain TWO more rows in it.
Here is part of my code:
...
//main panel with 1 row and 1 column
JPanel mainPanel = new JPanel();
mainPanel.setLayout( new GridLayout(1, 1) );
//create the 2 rows in the main panel
JPanel subpanelA = new JPanel();
subpanelA.setLayout(new GridLayout(2,1));
JPanel subpanelA1 = new JPanel();
subpanelA1.setLayout(new FlowLayout());
JLabel label1 = new JLabel("ROW 1");
subpanelA1.add(label1);
JPanel subpanelA2 = new JPanel();
subpanelA1.setLayout(new FlowLayout());
JLabel label2 = new JLabel("ROW 2");
subpanelA2.add(label2);
...
when it's compiled, "ROW 1" and "ROW 2" appears on the same row, HOWEVER, i have to make it appear on its own separate rows.
can someone tell me what i did wrong or what i need to add to the code?
:)