java - Breaking one grid layout into two pieces -
i want split grid layout filled buttons 2 pieces, first 5 buttons can go north of borderlayout
, last 5 can go south.
mypanel = new jpanel(new gridlayout(10, 1, 5, 10)); final jpanel mainpanel = new jpanel(new borderlayout());
there number of options, using single panel, can change gridlayout
properties allow 5 columns , 2 rows...
jpanel panel = new jpanel(new gridlayout(2, 10)); (int index = 0; index < 10; index++) { panel.add(new jbutton(integer.tostring(index))); }
or, make use 3 panels, 1 acting outer container, defining rows, , others defining rows
jpanel outer = new jpanel(new gridlayout(2, 1)); jpanel toprow = new jpanel(new gridlayout(1, 5)); (int index = 0; index < 5; index++) { toprow.add(new jbutton(integer.tostring(index))); } jpanel bottomrow = new jpanel(new gridlayout(1, 5)); (int index = 5; index < 10; index++) { bottomrow.add(new jbutton(integer.tostring(index))); } outer.add(toprow); outer.add(bottomrow);
Comments
Post a Comment