Hi,
I am trying to create a grid which contains three rows, within each row there will be various buttons also in gridlayout.
There are 20 buttons in the middle row, 3 in the top and 4 at the bottom. I want the top and bottom buttons to be of comparable size to the buttons in the centre row. However, each row of the gridlayout is the same size so, as a result, the top and bottom buttons are huge and the central ones are squeezed. I don't know how to fix it. Here is the code I've got. Any help would be appreciated:
import java.awt.*;
public class NestedPanel extends Frame {
public NestedPanel(String title) {
super(title);
setLayout(new GridLayout(3,1,0,40));
addPanel1();
addPanel2();
addPanel3();
}
public void addPanel1() {
Panel panel = new Panel();
panel.setLayout(new GridLayout(0,3,15,0));
panel.add(new Button("TButton X"));
panel.add(new Button("TButton Y"));
panel.add(new Button("TButton Z"));
add(panel);
}
public void addPanel2() {
Panel panel = new Panel();
panel.setLayout(new GridLayout(4,5));
for(int i=1;i<=20;i++)
{
panel.add(new Button("Button " + i));
}
add(panel);
}
public void addPanel3() {
Panel panel = new Panel();
panel.setLayout(new GridLayout(0,4,15,30));
panel.add(new Button("BButton X"));
panel.add(new Button("BButton Y"));
panel.add(new Button("BButton Z"));
panel.add(new Button("BButton Q"));
add(BorderLayout.SOUTH,panel);
}
public static void main(String[] args) {
NestedPanel abc =
new NestedPanel("Nested Panel");
abc.setSize(350, 550);
abc.setVisible(true);
}
}