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
public boolean equals(Object o)
Object
public boolean isConstraintTracking()
Layout
isConstraintTracking
in class Layout
public boolean isGrowHorizontally()
public void setGrowHorizontally(boolean growHorizontally)
growHorizontally
- the growHorizontally to set