G
gk
Frame f = new Frame("Question 3");
f.setLayout(new GridLayout(2,3));
for(int i=0;i<(int)Math.round(6.51);i++){
f.add(new Button(""+(i+1)));
}
f.pack();
f.validate();
f.setVisible(true);
the output is not understable.
the output button is
1 2 3 4
5 6 7
Question :
why the output is like this ?
see, we have GridLayout(2,3) , this means its a 2x3 grid .....right ?
so basically there should be 6 cells...like below
c1 c2 c3
c4 c5 c6
and the button should be placed serially on these cells...and as a
result we should not see also the 7th button.
so, my proposed solution is :
1 2 3
4 5 6
Now tell me, where is the mistake in my solution......why the real
solution does not match with my answer ?
f.setLayout(new GridLayout(2,3));
for(int i=0;i<(int)Math.round(6.51);i++){
f.add(new Button(""+(i+1)));
}
f.pack();
f.validate();
f.setVisible(true);
the output is not understable.
the output button is
1 2 3 4
5 6 7
Question :
why the output is like this ?
see, we have GridLayout(2,3) , this means its a 2x3 grid .....right ?
so basically there should be 6 cells...like below
c1 c2 c3
c4 c5 c6
and the button should be placed serially on these cells...and as a
result we should not see also the 7th button.
so, my proposed solution is :
1 2 3
4 5 6
Now tell me, where is the mistake in my solution......why the real
solution does not match with my answer ?