Why when I run this code the window has 3 columns and 10 rows? I thought that it should have 10 columns and 10 rows.
Code:
JFrame frame = new JFrame();
Container container = frame.getContentPane();
container.setLayout(new GridLayout(10,10));
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
if (i >= j) {
container.add(new JButton("X"));
} else {
container.add(new JLabel("*"));
}
}
}
frame.setSize(500, 500);
frame.setVisible(true);