acm.gui
Class TableConstraints

java.lang.Object
  extended by java.awt.GridBagConstraints
      extended by acm.gui.TableConstraints
All Implemented Interfaces:
Serializable, Cloneable

public class TableConstraints
extends GridBagConstraints

This class specifies a set of constraints appropriate to a TableLayout or GridBagLayout. It has the following advantages over the GridBagConstraints class on which it is based:

To create a TableConstraints object, use the constructor with a string argument to set the fields of the underlying GridBagConstraints object. For example, suppose you wanted to achieve the effect of the traditional code


      GridBagConstraints gbc = new GridBagConstraints();
      gbc.gridx = 2;
      gbc.gridy = 3;
      gbc.fill = GridBagConstraints.BOTH;
 

Using TableConstraints, you can do all of this with the constructor, as follows:


      new TableConstraints("gridx=2 gridy=3 fill=BOTH");
 

See Also:
Serialized Form

Field Summary
 int height
          Specifies the desired height of this cell.
protected static String[] LEGAL_KEYS
           
 int width
          Specifies the desired width of this cell.
 
Fields inherited from class java.awt.GridBagConstraints
anchor, BOTH, CENTER, EAST, fill, FIRST_LINE_END, FIRST_LINE_START, gridheight, gridwidth, gridx, gridy, HORIZONTAL, insets, ipadx, ipady, LAST_LINE_END, LAST_LINE_START, LINE_END, LINE_START, NONE, NORTH, NORTHEAST, NORTHWEST, PAGE_END, PAGE_START, RELATIVE, REMAINDER, SOUTH, SOUTHEAST, SOUTHWEST, VERTICAL, weightx, weighty, WEST
 
Constructor Summary
TableConstraints()
          Creates a new TableConstraints object with default values for each of the fields.
TableConstraints(GridBagConstraints gbc)
          Creates a new TableConstraints object whose fields match those of the specified GridBagConstraints object.
TableConstraints(Map<String,String> map)
          Creates a new TableConstraints object whose components are the key/value pairs in the map.
TableConstraints(String str)
          Creates a new TableConstraints object whose components are initialized according from the specified string.
 
Method Summary
 int getAnchor()
          Returns the anchor field from the constraint.
 int getFill()
          Returns the fill field from the constraint.
 int getGridHeight()
          Returns the gridheight field from the constraint.
 int getGridWidth()
          Returns the gridwidth field from the constraint.
 int getGridX()
          Returns the gridx field from the constraint.
 int getGridY()
          Returns the gridy field from the constraint.
 int getHeight()
          Returns the height field from the constraint.
 Insets getInsets()
          Returns the insets field from the constraint.
 int getIPadX()
          Returns the ipadx field from the constraint.
 int getIPadY()
          Returns the ipady field from the constraint.
 double getWeightX()
          Returns the weightx field from the constraint.
 double getWeightY()
          Returns the weighty field from the constraint.
 int getWidth()
          Returns the width field from the constraint.
 String toString()
          Converts the constraint into a readable string.
 
Methods inherited from class java.awt.GridBagConstraints
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

height

public int height
Specifies the desired height of this cell. The height of a row is taken to be the maximum of the specified cell heights. If this field has its default value of 0, the height is taken from the preferred size of the component.


LEGAL_KEYS

protected static final String[] LEGAL_KEYS

width

public int width
Specifies the desired width of this cell. The width of a column is taken to be the maximum of the specified cell widths. If this field has its default value of 0, the width is taken from the preferred size of the component.

Constructor Detail

TableConstraints

public TableConstraints()
Creates a new TableConstraints object with default values for each of the fields.


TableConstraints

public TableConstraints(GridBagConstraints gbc)
Creates a new TableConstraints object whose fields match those of the specified GridBagConstraints object. Clients will not ordinarily need to call this version of the constructor.

Parameters:
gbc - The GridBagConstraints object to copy

TableConstraints

public TableConstraints(Map<String,String> map)
Creates a new TableConstraints object whose components are the key/value pairs in the map.

Parameters:
map - A map containing the key/value pairs

TableConstraints

public TableConstraints(String str)
Creates a new TableConstraints object whose components are initialized according from the specified string. Each field is initialized by specifying a binding in the form


      key=value
 

where key is the name of one of the public fields in the TableConstraints class and value is the corresponding value, which can be expressed either as an integer or as one of the constant names appropriate to that field. For example, the string


      "width=20 fill=BOTH"
 

would create a TableConstraints object whose width field was set to 20 and whose fill field was set the the constant GridBagConstraints.BOTH.

As a special case, the four elements of the insets field can be set using the key names left, right, top, and bottom. Also, because the names are more likely to indicate their purposes to novices, the HTML names rowspan and colspan can be used in place of gridwidth and gridheight.

Parameters:
str - The constraint string as a series of key/value pairs
Method Detail

getAnchor

public int getAnchor()
Returns the anchor field from the constraint.

Returns:
The anchor field from the constraint

getFill

public int getFill()
Returns the fill field from the constraint.

Returns:
The fill field from the constraint

getGridHeight

public int getGridHeight()
Returns the gridheight field from the constraint.

Returns:
The gridheight field from the constraint

getGridWidth

public int getGridWidth()
Returns the gridwidth field from the constraint.

Returns:
The gridwidth field from the constraint

getGridX

public int getGridX()
Returns the gridx field from the constraint.

Returns:
The gridx field from the constraint

getGridY

public int getGridY()
Returns the gridy field from the constraint.

Returns:
The gridy field from the constraint

getHeight

public int getHeight()
Returns the height field from the constraint.

Returns:
The height field from the constraint

getInsets

public Insets getInsets()
Returns the insets field from the constraint.

Returns:
The insets field from the constraint

getIPadX

public int getIPadX()
Returns the ipadx field from the constraint.

Returns:
The ipadx field from the constraint

getIPadY

public int getIPadY()
Returns the ipady field from the constraint.

Returns:
The ipady field from the constraint

getWeightX

public double getWeightX()
Returns the weightx field from the constraint.

Returns:
The weightx field from the constraint

getWeightY

public double getWeightY()
Returns the weighty field from the constraint.

Returns:
The weighty field from the constraint

getWidth

public int getWidth()
Returns the width field from the constraint.

Returns:
The width field from the constraint

toString

public String toString()
Converts the constraint into a readable string.

Overrides:
toString in class Object
Returns:
A readable string version of the constraint