public class TableLayout extends Layout
Modifier and Type | Class and Description |
---|---|
static class |
TableLayout.Constraint
Represents the layout constraint for an entry within the table indicating
the desired position/behavior of the component.
|
Constructor and Description |
---|
TableLayout(int rows,
int columns)
A table must declare the amount of rows and columns in advance
|
Modifier and Type | Method and Description |
---|---|
void |
addLayoutComponent(Object value,
Component comp,
Container c)
Some layouts can optionally track the addition of elements with meta-data
that allows the user to "hint" on object positioning.
|
TableLayout.Constraint |
createConstraint()
Creates a new Constraint instance to add to the layout
|
TableLayout.Constraint |
createConstraint(int row,
int column)
Creates a new Constraint instance to add to the layout
|
boolean |
equals(Object o)
Indicates whether some other object is "equal to" this one.
|
int |
getCellHorizontalSpan(int row,
int column)
Returns the spanning for the table cell at the given coordinate
|
int |
getCellVerticalSpan(int row,
int column)
Returns the spanning for the table cell at the given coordinate
|
int |
getColumnPosition(int col)
Returns the position of the given table column.
|
int |
getColumns()
Get the number of columns
|
Component |
getComponentAt(int row,
int column)
Returns the component at the given row/column
|
Object |
getComponentConstraint(Component comp)
Returns the optional component constraint
|
static int |
getDefaultColumnWidth()
Indicates the default (in percentage) for the column width, -1 indicates
automatic sizing
|
static int |
getDefaultRowHeight()
Indicates the default (in percentage) for the row height, -1 indicates
automatic sizing
|
static int |
getMinimumSizePerColumn()
Indicates the minimum size for a column in the table, this is applicable for tables that are
not scrollable on the X axis.
|
int |
getNextColumn()
Returns the column where the next operation of add will appear
|
int |
getNextRow()
Returns the row where the next operation of add will appear
|
Dimension |
getPreferredSize(Container parent)
Returns the container preferred size
|
int |
getRowPosition(int row)
Returns the position of the given table row.
|
int |
getRows()
Get the number of rows
|
boolean |
hasHorizontalSpanning()
Indicates whether there is spanning within this layout
|
boolean |
hasVerticalSpanning()
Indicates whether there is spanning within this layout
|
boolean |
isCellSpannedThroughHorizontally(int row,
int column)
Returns true if the cell at the given position is spanned through horizontally
|
boolean |
isCellSpannedThroughVertically(int row,
int column)
Returns true if the cell at the given position is spanned through vertically
|
boolean |
isConstraintTracking()
If this method returns true, the addLayoutComponent method will be called when replacing a
layout for every component within the container
|
boolean |
isGrowHorizontally()
Indicates whether the table layout should grow horizontally to take up available space by stretching the last column
|
void |
layoutContainer(Container parent)
Layout the given parent container children
|
void |
removeLayoutComponent(Component comp)
Removes the component from the layout this operation is only useful if the
layout maintains references to components within it
|
static void |
setDefaultColumnWidth(int w)
Indicates the default (in percentage) for the column width, -1 indicates
automatic sizing
|
static void |
setDefaultRowHeight(int h)
Indicates the default (in percentage) for the row height, -1 indicates
automatic sizing
|
void |
setGrowHorizontally(boolean growHorizontally)
Indicates whether the table layout should grow horizontally to take up available space by stretching the last column
|
static void |
setMinimumSizePerColumn(int minimumSize)
Sets the minimum size for a column in the table, this is applicable for tables that are
not scrollable on the X axis.
|
String |
toString()
Returns a string representation of the object.
|
hashCode, isOverlapSupported, obscuresPotential
public TableLayout(int rows, int columns)
rows
- rows of the tablecolumns
- columns of the tablepublic int getRows()
public int getColumns()
public Component getComponentAt(int row, int column)
row
- the row of the componentcolumn
- the column of the componentpublic void layoutContainer(Container parent)
Layout
layoutContainer
in class Layout
parent
- the given parent containerpublic int getRowPosition(int row)
row
- the row in the tablepublic int getColumnPosition(int col)
col
- the column in the tablepublic Dimension getPreferredSize(Container parent)
Layout
getPreferredSize
in class Layout
parent
- the parent containerpublic int getNextRow()
public int getNextColumn()
public void addLayoutComponent(Object value, Component comp, Container c)
Layout
addLayoutComponent
in class Layout
value
- optional meta data information, like alignment orientationcomp
- the added component to the layoutc
- the parent containerpublic int getCellHorizontalSpan(int row, int column)
row
- row in the tablecolumn
- column within the tablepublic int getCellVerticalSpan(int row, int column)
row
- row in the tablecolumn
- column within the tablepublic boolean isCellSpannedThroughVertically(int row, int column)
row
- cell rowcolumn
- cell columnpublic boolean isCellSpannedThroughHorizontally(int row, int column)
row
- cell rowcolumn
- cell columnpublic boolean hasVerticalSpanning()
public boolean hasHorizontalSpanning()
public void removeLayoutComponent(Component comp)
Layout
removeLayoutComponent
in class Layout
comp
- the removed component from layoutpublic Object getComponentConstraint(Component comp)
Layout
getComponentConstraint
in class Layout
comp
- the component whose constraint should be returnedpublic TableLayout.Constraint createConstraint()
public TableLayout.Constraint createConstraint(int row, int column)
row
- the row for the table starting with 0column
- the column for the table starting with 0public static void setMinimumSizePerColumn(int minimumSize)
minimumSize
- the minimum width of the columnpublic static int getMinimumSizePerColumn()
public static void setDefaultColumnWidth(int w)
w
- width in percentagepublic static int getDefaultColumnWidth()
public static void setDefaultRowHeight(int h)
h
- height in percentagepublic static int getDefaultRowHeight()
public String toString()
Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public boolean equals(Object o)
Object
The equals
method implements an equivalence relation
on non-null object references:
x
, x.equals(x)
should return
true
.
x
and y
, x.equals(y)
should return true
if and only if
y.equals(x)
returns true
.
x
, y
, and z
, if
x.equals(y)
returns true
and
y.equals(z)
returns true
, then
x.equals(z)
should return true
.
x
and y
, multiple invocations of
x.equals(y)
consistently return true
or consistently return false
, provided no
information used in equals
comparisons on the
objects is modified.
x
,
x.equals(null)
should return false
.
The equals
method for class Object
implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x
and
y
, this method returns true
if and only
if x
and y
refer to the same object
(x == y
has the value true
).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the
general contract for the hashCode
method, which states
that equal objects must have equal hash codes.
equals
in class Layout
o
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
HashMap
public boolean isConstraintTracking()
Layout
isConstraintTracking
in class Layout
public boolean isGrowHorizontally()
public void setGrowHorizontally(boolean growHorizontally)
growHorizontally
- the growHorizontally to set