Package com.evanmclean.evlib.tablelayout

Utilities to make it easier dealing with TableLayouts.

See:
          Description

Interface Summary
TL Shorthand for table layout column/row specifications.
 

Class Summary
TableLayoutConstraintFactory Utility to make it easy to create TableLayoutConstraint objects for the TableLayout layout manager.
TableLayoutFactory Utility to make it easy to create TableLayout objects with the specified rows and columns.
 

Enum Summary
TLHA Shorthand enumerated type for TableLayout vertical alignments.
TLVA Shorthand enumerated type for TableLayout vertical alignments.
 

Exception Summary
TLCFException Runtime exceptions that can be thrown by the TableLayoutConstraintFactory.
TLFException Runtime exceptions that can be thrown by the TableLayoutFactory.
 

Package com.evanmclean.evlib.tablelayout Description

Utilities to make it easier dealing with TableLayouts.

You generally use the TableLayoutFactory to create a correctly configured TableLayout object, and the TableLayoutConstraintFactory to specify the constraints for each child component.

e.g. For making the following form:

     +-------------------------------------+
     |        ---------------------------  |
     | File: |                           | |
     |        ---------------------------  |
     |                                     |
     |                             ------  |
     |                            | OKAY | |
     |                             ------  |
     +-------------------------------------+

The form is comprised of three columns and two rows. The code to build this would look something like:

TableLayout layout = TableLayoutFactory
.build(5)
.fillcols(false, true, false)
.fillrows(false, false)
.make();

TableLayoutConstraintFactory const = new TableLayoutConstraintFactory(layout);

JPanel panel = new JPanel(layout);

JLabel label = new JLabel("File:");
panel.add(label, const.build(0, 0).right().vcentre().make());

JTextField path = new JTextField();
panel.add(path, const.build(1, 0).hfull().vfull().width(2).make());

JButton okay = new JButton("Okay");
panel.add(path, const.build(2, 1).right().vfull().make());

First we construct a table layout with vertical and horizontal gaps of 5. The fillcols call takes a variable number of booleans, indicating which columns use preferred sizing and which stretch (and specifies the number of columns while doing so). The fillrows call does the same for the rows of the table layout, and then make actually constructs the layout object.

In this case, we wanted the middle column of the layout to be stretchy, while the other two columns stick with the preferred size of their components.

Then we create the constraint factory helper object, which we'll use when adding components to the form.

We create the panel which will represent our form, giving it the table layout object to handle its layout of components.

We add the label component in column 0, row 0 of the panel, telling the layout that the component should be right justified and vertically centred.

We then add the text field in column 1 of the same row, but this time the component should fill the cells both horizonally and vertically. The text field should also fill up two cells (the width).

Lastly, we have the okay button, which goes on the second row (row 1) and the last column (column 2), be right justified but fill the cell vertically.