uic.layout
Class Constraints

java.lang.Object
  extended byuic.layout.Constraints
Direct Known Subclasses:
Entry

public class Constraints
extends Object

In finding a place in the grid of the NaturalLayout you can add a Constraints object add adding the widget to the parent.

   JPanel parent = new JPanel(new NaturalLayout(10, 10));
   parent.add(myChildWidget, new Constraint("0,0");
 

The different constructors in this class will give you more hints to the options you have. The most convenient method of adding a widget is using the constructor that takes a formatted String. You can even leave away the invocation of a new Constraints object so your add could look like:

    parent.add(myChildWidget, "1,0, 2,0");
 

Since:
1.1
See Also:
NaturalLayout

Field Summary
static char ALIGN_HORIZONTAL_CENTER
           
static char ALIGN_HORIZONTAL_FILLED
           
static char ALIGN_HORIZONTAL_LEFT
           
static char ALIGN_HORIZONTAL_RIGHT
           
static char ALIGN_VERTICAL_BOTTOM
           
static char ALIGN_VERTICAL_CENTER
           
static char ALIGN_VERTICAL_FILLED
           
static char ALIGN_VERTICAL_TOP
           
protected  int col1
          Cell in which the upper left corner of the component lays
protected  int col2
          Cell in which the lower right corner of the component lays
protected  int hAlign
          justification
protected  int horizontalPolicy
          sizing policies
protected  int row1
          Cell in which the upper left corner of the component lays
protected  int row2
          Cell in which the lower right corner of the component lays
static String SIZE_POLICY_EXPANDING
           
static String SIZE_POLICY_FIXED
           
static String SIZE_POLICY_IGNORED
           
static String SIZE_POLICY_MAXIMUM
           
static String SIZE_POLICY_MINIMUM
           
static String SIZE_POLICY_MINIMUM_EXPANDING
           
static String SIZE_POLICY_PREFERRED
           
protected  int vAlign
          justification
protected  int verticalPolicy
          sizing policies
 
Constructor Summary
Constraints()
          Constructs an Constraints with the default settings.
Constraints(int col1, int row1, int col2, int row2, int hAlign, int vAlign)
           
Constraints(int col1, int row1, int col2, int row2, int hAlign, int vAlign, int horizontalPolicy, int verticalPolicy)
          Constructs an Constraints a set of constraints.
Constraints(String constraints)
          Constructs an Constraints from a string.
 
Method Summary
 String toString()
          Gets a string representation of this Constraints.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALIGN_HORIZONTAL_LEFT

public static final char ALIGN_HORIZONTAL_LEFT
See Also:
Constant Field Values

ALIGN_HORIZONTAL_RIGHT

public static final char ALIGN_HORIZONTAL_RIGHT
See Also:
Constant Field Values

ALIGN_HORIZONTAL_CENTER

public static final char ALIGN_HORIZONTAL_CENTER
See Also:
Constant Field Values

ALIGN_HORIZONTAL_FILLED

public static final char ALIGN_HORIZONTAL_FILLED
See Also:
Constant Field Values

ALIGN_VERTICAL_TOP

public static final char ALIGN_VERTICAL_TOP
See Also:
Constant Field Values

ALIGN_VERTICAL_BOTTOM

public static final char ALIGN_VERTICAL_BOTTOM
See Also:
Constant Field Values

ALIGN_VERTICAL_CENTER

public static final char ALIGN_VERTICAL_CENTER
See Also:
Constant Field Values

ALIGN_VERTICAL_FILLED

public static final char ALIGN_VERTICAL_FILLED
See Also:
Constant Field Values

SIZE_POLICY_FIXED

public static final String SIZE_POLICY_FIXED
See Also:
Constant Field Values

SIZE_POLICY_MINIMUM

public static final String SIZE_POLICY_MINIMUM
See Also:
Constant Field Values

SIZE_POLICY_MAXIMUM

public static final String SIZE_POLICY_MAXIMUM
See Also:
Constant Field Values

SIZE_POLICY_PREFERRED

public static final String SIZE_POLICY_PREFERRED
See Also:
Constant Field Values

SIZE_POLICY_MINIMUM_EXPANDING

public static final String SIZE_POLICY_MINIMUM_EXPANDING
See Also:
Constant Field Values

SIZE_POLICY_EXPANDING

public static final String SIZE_POLICY_EXPANDING
See Also:
Constant Field Values

SIZE_POLICY_IGNORED

public static final String SIZE_POLICY_IGNORED
See Also:
Constant Field Values

col1

protected int col1
Cell in which the upper left corner of the component lays


row1

protected int row1
Cell in which the upper left corner of the component lays


col2

protected int col2
Cell in which the lower right corner of the component lays


row2

protected int row2
Cell in which the lower right corner of the component lays


hAlign

protected int hAlign
justification


vAlign

protected int vAlign
justification


horizontalPolicy

protected int horizontalPolicy
sizing policies


verticalPolicy

protected int verticalPolicy
sizing policies

Constructor Detail

Constraints

public Constraints()
Constructs an Constraints with the default settings. This constructor is equivalent to Constraints(0, 0, 0, 0, NaturalLayout.ALIGN_FULL, NaturalLayout.ALIGN_FULL).


Constraints

public Constraints(String constraints)
Constructs an Constraints from a string. Using this constructor you will have all options available by creating a formatted string. The format build from 3 parts that can be left out at your choice; Examples:
"1,0" Widget in x=1 and y=0 and full alignment horizontal and vertical.
"1,0,1,1" Widget in both (1,0) and (1,1) with full alignment horizontal and vertical.
"1,0,C" Widget in (1,0) with centered alignment horizontal and full alignment vertical.
"1,0,L,B" Widget in (1,0) with left alignment horizontal and bottom alignment vertical.
"2,2,3,3,C,T" Widget in (2,2), (2,2), (3,2) and (3.3) with centerd alignment horizontal and top alignment vertical.

Parameters:
constraints - indicates Constraints's position and justification as a string in the form "column, row" or "column, row, horizontal justification, vertical justification" or "column 1, row 1, column 2, row 2". It is also acceptable to delimit the paramters with spaces instead of commas.

Constraints

public Constraints(int col1,
                   int row1,
                   int col2,
                   int row2,
                   int hAlign,
                   int vAlign)

Constraints

public Constraints(int col1,
                   int row1,
                   int col2,
                   int row2,
                   int hAlign,
                   int vAlign,
                   int horizontalPolicy,
                   int verticalPolicy)
Constructs an Constraints a set of constraints.

Parameters:
col1 - column where upper-left cornor of the component is placed
row1 - row where upper-left cornor of the component is placed
col2 - column where lower-right cornor of the component is placed
row2 - row where lower-right cornor of the component is placed
hAlign - horizontal justification of a component in a single cell
vAlign - vertical justification of a component in a single cell
horizontalPolicy - the sizing policy horizontally
verticalPolicy - the sizing policy vertically
Method Detail

toString

public String toString()
Gets a string representation of this Constraints.

Returns:
a string in the form "column 1, row 1, column 2, row 2" or "column, row, horizontal justification, vertical justification"


Copyright © 2002,2003 Thomas Zander Available under the Free Apache licence