info.clearthought.layout
Class ComponentArranger

java.lang.Object
  extended by info.clearthought.layout.ComponentArranger

public final class ComponentArranger
extends java.lang.Object

This builder creates a TableLayout based on an arrangement of components within a one-dimensional array. The array given by the user should contain a container at index 0, followed by a double or int for each column, followed by elements for each row of the layout. Each row should begin with a double or int for the row height, followed by zero or more components that occupy cells in that row. Components can span cells by being repeated in the array. Cells can be skipped by using nulls. Rows can be ended by indicating the next row start with a double or int. Below is an example that demonstrates all of these principles.

 ComponentArranger.arrange(5, 5, new Object []
     {contentPane,            TableLayout.PREFERRED, TableLayout.FILL,   TableLayout.PREFERRED,
      TableLayout.PREFERRED,  labelSource,           textboxSource,      buttonBrowseSource,
      TableLayout.PREFERRED,  labelDestination,      textboxDestination, buttonBrowseDestination,
      TableLayout.FILL,       null,                  scrollPane,         scrollPane,
      TableLayout.PREFERRED,  labelHi,               scrollPane,         scrollPane,
      5,
      TableLayout.PREFERRED,  panelButton,           panelButton,        panelButton});
 

Author:
Daniel E. Barbalace

Method Summary
static void alignComponent(TableLayout layout, java.awt.Component component, int hAlign, int vAlign)
          Aligns the given component in the given layout.
static TableLayout arrange(int hGap, int vGap, java.lang.Object[] array)
          Creates a TableLayout using the container, components, and row/column sizes in the given array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

alignComponent

public static void alignComponent(TableLayout layout,
                                  java.awt.Component component,
                                  int hAlign,
                                  int vAlign)
Aligns the given component in the given layout.

Parameters:
layout - Layout being altered.
component - Component whose alignment is being set.
hAlign - New horizontal alignment.
vAlign - New vertical alignment.

arrange

public static TableLayout arrange(int hGap,
                                  int vGap,
                                  java.lang.Object[] array)
Creates a TableLayout using the container, components, and row/column sizes in the given array. When this method returns the container in "array" will be using the TableLayout returned by this method. That container will also have all the components specified in "array".

Parameters:
hGap - Horizontal gap between columns.
vGap - Vertical gap between rows.
array - See examples in ComponentArranger class JavaDoc for details on how to construct this array.
Returns:
The TableLayout created.
See Also:
ComponentArranger