java - How to add jpanel to a specific cell of GridLayout -
in below code, created gridlayot 3 rows , 3 columns, want is,,to add jpanel_1 specifc cell of gridlayout, lets in grid cell number (2,3).
code:
private void setupgui2() { // todo auto-generated method stub jframe_2 = new jframe("border demo"); gridlayout gridlayout = new gridlayout(3,3); jframe_2.setlayout(gridlayout); jpanel_1 = new jpanel(new borderlayout()); jpanel_2 = new jpanel(new borderlayout()); jpanel_1.setborder(borderfactory.createtitledborder("title")); //jpanel_1.setbounds(30, 100, 110, 300); jpanel_1.add(jlabel_hello, borderlayout.east); jpanel_2.setborder(borderfactory.createloweredbevelborder()); //jpanel_2.setbounds(20, 50, 120, 80); jpanel_2.add(jlabel_hello, borderlayout.south); //jframe_2.setbounds(0, 0, 600, 600); jframe_2.add(jpanel_1);//how add jpanel_1 specific cell of gridlayout defined above //jpanel_1.add(jpanel_2); jframe_2.add(jpanel_2); jframe_2.pack(); jframe_2.setvisible(true); }
i think there no chance. need add them 1 one. frame.add(...); frame.add(...);
don't understand want result, using gridlayout(3, 3)
2 panels same use gridlayout(0, 2)
.
p.s. check out gridbaglayout - can more useful you.
Comments
Post a Comment