Two components in one column

Discussion on JDAL Swing Module

Moderator: Jose Luis Martin

Two components in one column

Postby ibanhoe » Mon Oct 13, 2014 9:18 pm

Hi, I just find your library for create screens with Java Swing.

I think it is very useful because you forget all about layout managerss stuffs....


But I have a question about the way that I can ad components to a BoxFormBuilder:

How can I add two componentes (with their labels) into the same column?

I mean, I have a row with one component, and for the second row, I want to add 2 components, and for the third row, I want to add only one component again.

I tried this:

Code: Select all
Box contacto = Box.createHorizontalBox();
      contacto.add("Compañía: ", companyTf);
      contacto.add("Contacto: ", contactTf);

      BoxFormBuilder fb = new BoxFormBuilder(
            BorderFactory.createTitledBorder(("Información")));
      fb.setFixedHeight(true);
      fb.row();
      fb.add("Id Máquina: ", idMachineTf);
      fb.row();
      fb.add("Id Dispositivo: ", idDeviceTf);
      fb.row();
      fb.add(contacto);


But with this code Im getting the screen in the attached image.

Thanks for your support...
ibanhoe
 
Posts: 1
Joined: Mon Oct 13, 2014 9:07 pm

Re: Two components in one column

Postby Jose Luis Martin » Fri Oct 17, 2014 8:24 pm

Hi ibanhoe,

Just create a new Box for grouping components using fb.startBox() method.

Code: Select all
BoxFormBuilder fb = new BoxFormBuilder();
fb.setDebug(true);  // useful when creating the form, drop when finished.
fb.setFixedHeight(true);

fb.row();              // firs row, one component
fb.startBox();         // this box is two component holder (Label and JTextField) but one for the parent
fb.add("Id Máquina: ", idMachineTf);
fb.endBox();
fb.row();              // second row
fb.startBox();         // start a new box to hold the 1x4 components
fb,row();              // first row of the inner box
fb.add("Compañía: ", companyTf);
fb.add("Contacto: ", contactTf);
endBox();              // end the box, the entire box count as one component for the parent form
fb.row();            // last row, one component again
fb.startBox()
fb.add("Id Dispositivo: ", idDeviceTf);
fb.endBox();   


Other option is creating a 3x2 matrix instead 3x1 as above, grouping the middle row in two box:

Code: Select all
fb.row();              // firs row, two component
fb.add("Id Máquina: ", idMachineTf);
fb.row();              // second row
fb.startBox();         // start a new box to hold the 1x2 components
fb.row();
fb.add("Compañía: ", companyTf);
fb.endBox();
fb.startBox();        // other  1x2 box in the same row
fb.row();
fb.add("Contacto: ", contactTf);
endBox();         
fb.row();              // last row, two component again
fb.add("Id Dispositivo: ", idDeviceTf);



See http://www.joseluismartin.info/jdal/box ... uilder.php for BoxFormBuilder documentation in Spanish.

Cheers
Jose Luis Martin
 
Posts: 39
Joined: Thu Jun 09, 2011 10:53 am


Return to JDAL Swing

Who is online

Users browsing this forum: No registered users and 2 guests

cron