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...

couple of 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

couple of more 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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -