Z
ZalekBloom
I am testing a GridLayout. Here is my program:
package Layouts;
import java.awt.* ;
public class test2 extends Frame {
public static void main(String[] args) {
GridLayout gl = new GridLayout(8,3);
Button b1 = new Button("Button 1") ;
Button b2 = new Button("Button 2") ;
Button b3 = new Button("Button 3") ;
Button b4 = new Button("Button 4") ;
Button b5 = new Button("Button 5") ;
Button b6 = new Button("Button 6") ;
Button b7 = new Button("Button 7") ;
Button b8 = new Button("Button 8") ;
Button b9 = new Button("Button 9") ;
test2 f = new test2() ;
f.setLayout(gl);
f.add(b1);
f.add(b2);
f.add(b3);
f.add(b4);
f.add(b5);
f.add(b6);
f.add(b7);
f.add(b8);
f.add(b9);
f.setSize(1000,1000);
f.setVisible(true);
}
}
I played with the statement: GridLayout gl = new GridLayout(8,3);
I noticed that if I am using GridLayout(9,3) - I see one column of 9 rows.
When I am using GridLayout(8,3) - I see 2 columns and 5 rows with buttons arranged:
1,2
3,4
5,6
7,8
9
My question: I understood froman old book it should be:
1,2,3
4,5,6
7,8,9
Where I can find an explanation about bottons position?
Thanks,
Zalek
package Layouts;
import java.awt.* ;
public class test2 extends Frame {
public static void main(String[] args) {
GridLayout gl = new GridLayout(8,3);
Button b1 = new Button("Button 1") ;
Button b2 = new Button("Button 2") ;
Button b3 = new Button("Button 3") ;
Button b4 = new Button("Button 4") ;
Button b5 = new Button("Button 5") ;
Button b6 = new Button("Button 6") ;
Button b7 = new Button("Button 7") ;
Button b8 = new Button("Button 8") ;
Button b9 = new Button("Button 9") ;
test2 f = new test2() ;
f.setLayout(gl);
f.add(b1);
f.add(b2);
f.add(b3);
f.add(b4);
f.add(b5);
f.add(b6);
f.add(b7);
f.add(b8);
f.add(b9);
f.setSize(1000,1000);
f.setVisible(true);
}
}
I played with the statement: GridLayout gl = new GridLayout(8,3);
I noticed that if I am using GridLayout(9,3) - I see one column of 9 rows.
When I am using GridLayout(8,3) - I see 2 columns and 5 rows with buttons arranged:
1,2
3,4
5,6
7,8
9
My question: I understood froman old book it should be:
1,2,3
4,5,6
7,8,9
Where I can find an explanation about bottons position?
Thanks,
Zalek