acm.gui
Class TableConstraints

java.lang.Object
  extended by java.awt.GridBagConstraints
      extended by acm.gui.TableConstraints

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");
 


Field Summary
 int height
Specifies the desired height of this cell.
 int width
Specifies the desired width of this cell.
 
Constructor Summary
TableConstraints()
Creates a new TableConstraints object with default values for each of the fields.
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.
 

Field Detail

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.


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

public TableConstraints()

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

 
Usage: TableConstraints constraints = new 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.


 
Usage: TableConstraints constraints = new TableConstraints(str); 
Parameter: 
str  The constraint string as a series of key/value pairs
 

Method Detail

public int getAnchor()

Returns the anchor field from the constraint.

 
Usage: int anchor = constraint.getAnchor(); 
Returns: The anchor field from the constraint
 


public int getFill()

Returns the fill field from the constraint.

 
Usage: int fill = constraint.getFill(); 
Returns: The fill field from the constraint
 


public int getGridHeight()

Returns the gridheight field from the constraint.

 
Usage: int gridheight = constraint.getGridHeight(); 
Returns: The gridheight field from the constraint
 


public int getGridWidth()

Returns the gridwidth field from the constraint.

 
Usage: int gridwidth = constraint.getGridWidth(); 
Returns: The gridwidth field from the constraint
 


public int getGridX()

Returns the gridx field from the constraint.

 
Usage: int gridx = constraint.getGridX(); 
Returns: The gridx field from the constraint
 


public int getGridY()

Returns the gridy field from the constraint.

 
Usage: int gridy = constraint.getGridY(); 
Returns: The gridy field from the constraint
 


public int getHeight()

Returns the height field from the constraint.

 
Usage: int height = constraint.getHeight(); 
Returns: The height field from the constraint
 


public Insets getInsets()

Returns the insets field from the constraint.

 
Usage: Insets insets = constraint.getInsets(); 
Returns: The insets field from the constraint
 


public int getIPadX()

Returns the ipadx field from the constraint.

 
Usage: int ipadx = constraint.getIPadX(); 
Returns: The ipadx field from the constraint
 


public int getIPadY()

Returns the ipady field from the constraint.

 
Usage: int ipady = constraint.getIPadY(); 
Returns: The ipady field from the constraint
 


public double getWeightX()

Returns the weightx field from the constraint.

 
Usage: double weightx = constraint.getWeightX(); 
Returns: The weightx field from the constraint
 


public double getWeightY()

Returns the weighty field from the constraint.

 
Usage: double weighty = constraint.getWeightY(); 
Returns: The weighty field from the constraint
 


public int getWidth()

Returns the width field from the constraint.

 
Usage: int width = constraint.getWidth(); 
Returns: The width field from the constraint