swing - GridBagLayouts in GridLayout -


trying build gui in swing:

enter image description here

in mainframe set gridlayout achieve 1 row, 2 columns:

setlayout(new gridlayout(1, 2)); 

in left column figures need gridbaglayout in right column. normal gridlayout doesn't work anymore because want different sizes of each row. left column tried this:

gridbagconstraints gbc = new gridbagconstraints();      mappanel = new mappanel(map);     gbc.fill = gridbagconstraints.both;     gbc.gridx = 0;     gbc.gridy = 0;     gbc.gridheight = 10;     add(mappanel, gbc);      controlpanel = new jpanel();     controlpanel.add(new jbutton("test"));     controlpanel.add(new jbutton("test 2"));     controlpanel.add(new jbutton("test 3"));     controlpanel.add(new jbutton("test 4"));     gbc.fill = gridbagconstraints.both;     gbc.gridx = 0;     gbc.gridy = 1;     gbc.gridheight = 1;     add(controlpanel, gbc);      logpanel = new logpanel();     gbc.fill = gridbagconstraints.both;     gbc.gridx = 0;     gbc.gridy = 2;     gbc.gridheight = gridbagconstraints.remainder;     add(logpanel, gbc); 

this result in "packed together" in left column. won't expand 100% height , 50% width column has. how can achieve gui in picture?

thanks!

look @ jnodelayout. rectnode need.

import java.awt.borderlayout; import java.awt.color; import java.awt.container; import java.awt.geom.rectangle2d;  import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.border.emptyborder; import javax.swing.border.lineborder;  import com.smartg.swing.layout.jnodelayout; import com.smartg.swing.layout.layoutnode.rectnode;  public class rectnodedemo {      public static void main(string[] args) {          string rootname = "root";         rectnode root = new rectnode(rootname);         jnodelayout layout = new jnodelayout(root);         layout.sethgap(1);         layout.setvgap(1);           jpanel target = new jpanel();         target.setborder(new emptyborder(10, 10, 10, 10));          target.setlayout(layout);          addpanel(target, root, new rectangle2d.double(0, 0, .5, .5));         addpanel(target, root, new rectangle2d.double(0, .5, .5, .1));         addpanel(target, root, new rectangle2d.double(0, .6, .5, .4));            addpanel(target, root, new rectangle2d.double(.5, 0, .5, .9));         addpanel(target, root, new rectangle2d.double(.5, .9, .5, .1));          layout.syncnodes();          jframe frame = new jframe();          container contentpane = frame.getcontentpane();         contentpane.setlayout(new borderlayout());         contentpane.add(target, borderlayout.center);         frame.pack();         frame.setvisible(true);     }      static void addpanel(jpanel target, rectnode node, rectangle2d r) {         jpanel p = new jpanel();         target.add(p);         p.setborder(new lineborder(color.black, 1));         node.add(p, r);     } } 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -