public class TableConstraints
extends java.awt.GridBagConstraints
TableLayout
or GridBagLayout
. It has the following
advantages over the GridBagConstraints
class on which it is
based:
width
and height
fields
that can be used with TableLayout
to specify minimum heights and
widths for rows and columns.
getGridX
and so forth)
so that clients can operate as if the fields are private.
toString
method that displays
nondefault values of the fields in a readable way.
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");
Modifier and Type | Field and Description |
---|---|
int |
height
Specifies the desired height of this cell.
|
protected static java.lang.String[] |
LEGAL_KEYS
Array of legal keys
|
int |
width
Specifies the desired width of this cell.
|
ABOVE_BASELINE, ABOVE_BASELINE_LEADING, ABOVE_BASELINE_TRAILING, anchor, BASELINE, BASELINE_LEADING, BASELINE_TRAILING, BELOW_BASELINE, BELOW_BASELINE_LEADING, BELOW_BASELINE_TRAILING, 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 and Description |
---|
TableConstraints()
Creates a new
TableConstraints object with default values for
each of the fields. |
TableConstraints(java.awt.GridBagConstraints gbc)
Creates a new
TableConstraints object whose fields match those
of the specified GridBagConstraints object. |
TableConstraints(java.util.Map<java.lang.String,java.lang.String> map)
Creates a new
TableConstraints object whose components are the
key/value pairs in the map. |
TableConstraints(java.lang.String str)
Creates a new
TableConstraints object whose components are
initialized according from the specified string. |
Modifier and Type | Method and Description |
---|---|
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. |
java.awt.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. |
java.lang.String |
toString()
Converts the constraint into a readable string.
|
public int width
public int height
protected static final java.lang.String[] LEGAL_KEYS
public TableConstraints()
TableConstraints
object with default values for
each of the fields.public TableConstraints(java.lang.String str)
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
.
str
- The constraint string as a series of key/value pairspublic TableConstraints(java.util.Map<java.lang.String,java.lang.String> map)
TableConstraints
object whose components are the
key/value pairs in the map.map
- A map containing the key/value pairspublic TableConstraints(java.awt.GridBagConstraints gbc)
TableConstraints
object whose fields match those
of the specified GridBagConstraints
object. Clients will not
ordinarily need to call this version of the constructor.gbc
- The GridBagConstraints
object to copypublic int getAnchor()
anchor
field from the constraint.anchor
field from the constraintpublic int getFill()
fill
field from the constraint.fill
field from the constraintpublic int getGridX()
gridx
field from the constraint.gridx
field from the constraintpublic int getGridY()
gridy
field from the constraint.gridy
field from the constraintpublic int getGridWidth()
gridwidth
field from the constraint.gridwidth
field from the constraintpublic int getGridHeight()
gridheight
field from the constraint.gridheight
field from the constraintpublic int getIPadX()
ipadx
field from the constraint.ipadx
field from the constraintpublic int getIPadY()
ipady
field from the constraint.ipady
field from the constraintpublic java.awt.Insets getInsets()
insets
field from the constraint.insets
field from the constraintpublic double getWeightX()
weightx
field from the constraint.weightx
field from the constraintpublic double getWeightY()
weighty
field from the constraint.weighty
field from the constraintpublic int getWidth()
width
field from the constraint.width
field from the constraintpublic int getHeight()
height
field from the constraint.height
field from the constraintpublic java.lang.String toString()
toString
in class java.lang.Object