Package com.bc.ceres.swing
Class TableLayout
java.lang.Object
com.bc.ceres.swing.TableLayout
- All Implemented Interfaces:
LayoutManager
,LayoutManager2
A convenient layout manager that allows multiple components to be laid out
in form of a table-like grid.
It uses the same parameters as Swing's standard GridBagLayout
manager, however clients
don't have to deal with GridBagConstraints
. Instead, they can easily use the
the various setters to adjust single parameters. Parameters can be specified for
- the entire table:
setTable<Param>()
, - an entire row:
setRow<Param>()
, - an entire column:
setColumn<Param>()
, - each cell separately:
setCell<Param>()
.
fill
and
anchor
parameter values.
Any parameter settings may be removed from the layout by passing null
as value.
Components are added to their container using a cell(row, col)
or
cell(row, col, rowspan, colspan)
constraint, for example:
panel.add(new JLabel("Iterations:"), TableLayout.cell(0, 3));
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
This parameter is used when the component's display area is larger than the component's requested size.static class
static enum
This parameter is used when the component is smaller than its display area. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLayoutComponent
(Component comp, Object constraints) Adds the specified component to the layout, using the specified constraint object.void
addLayoutComponent
(String name, Component comp) Has no effect, since this layout manager does not use a per-component string.static TableLayout.Cell
cell()
static TableLayout.Cell
cell
(int row, int col) static TableLayout.Cell
cell
(int row, int col, int rowspan, int colspan) int
float
getLayoutAlignmentX
(Container target) Returns the alignment along the x axis.float
getLayoutAlignmentY
(Container target) Returns the alignment along the y axis.void
invalidateLayout
(Container target) Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.void
layoutContainer
(Container parent) Lays out the specified container.maximumLayoutSize
(Container parent) Calculates the maximum size dimensions for the specified container, given the components it contains.minimumLayoutSize
(Container parent) Calculates the minimum size dimensions for the specified container, given the components it contains.preferredLayoutSize
(Container parent) Calculates the preferred size dimensions for the specified container, given the components it contains.void
Removes the specified component from the layout.void
setCellAnchor
(int row, int col, TableLayout.Anchor anchor) void
setCellColspan
(int row, int col, Integer colspan) void
setCellFill
(int row, int col, TableLayout.Fill fill) void
setCellPadding
(int row, int col, Insets insets) void
setCellRowspan
(int row, int col, Integer rowspan) void
setCellWeightX
(int row, int col, Double weightx) void
setCellWeightY
(int row, int col, Double weighty) void
setColumnAnchor
(int col, TableLayout.Anchor anchor) void
setColumnCount
(int columnCount) void
setColumnFill
(int col, TableLayout.Fill fill) void
setColumnPadding
(int col, Insets insets) void
setColumnWeightX
(int col, Double weightx) void
setColumnWeightY
(int col, Double weighty) void
setRowAnchor
(int row, TableLayout.Anchor anchor) void
setRowFill
(int row, TableLayout.Fill fill) void
setRowPadding
(int row, Insets insets) void
setRowWeightX
(int row, Double weightx) void
setRowWeightY
(int row, Double weighty) void
setTableAnchor
(TableLayout.Anchor anchor) void
setTableFill
(TableLayout.Fill fill) void
setTablePadding
(int hpadding, int vpadding) void
setTablePadding
(Insets insets) void
setTableWeightX
(Double weightx) void
setTableWeightY
(Double weighty) toString()
-
Constructor Details
-
TableLayout
public TableLayout() -
TableLayout
public TableLayout(int columnCount)
-
-
Method Details
-
getColumnCount
public int getColumnCount() -
setColumnCount
public void setColumnCount(int columnCount) -
setCellColspan
-
setCellRowspan
-
setTablePadding
public void setTablePadding(int hpadding, int vpadding) -
setTablePadding
-
setRowPadding
-
setColumnPadding
-
setCellPadding
-
setTableWeightX
-
setRowWeightX
-
setColumnWeightX
-
setCellWeightX
-
setTableWeightY
-
setRowWeightY
-
setColumnWeightY
-
setCellWeightY
-
setTableFill
-
setRowFill
-
setColumnFill
-
setCellFill
-
setTableAnchor
-
setRowAnchor
-
setColumnAnchor
-
setCellAnchor
-
createHorizontalSpacer
-
createVerticalSpacer
-
getLayoutAlignmentX
Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.- Specified by:
getLayoutAlignmentX
in interfaceLayoutManager2
-
getLayoutAlignmentY
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.- Specified by:
getLayoutAlignmentY
in interfaceLayoutManager2
-
invalidateLayout
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.- Specified by:
invalidateLayout
in interfaceLayoutManager2
-
addLayoutComponent
Adds the specified component to the layout, using the specified constraint object.- Specified by:
addLayoutComponent
in interfaceLayoutManager2
- Parameters:
comp
- the component to be addedconstraints
- where/how the component is added to the layout.
-
addLayoutComponent
Has no effect, since this layout manager does not use a per-component string.- Specified by:
addLayoutComponent
in interfaceLayoutManager
-
removeLayoutComponent
Removes the specified component from the layout.- Specified by:
removeLayoutComponent
in interfaceLayoutManager
- Parameters:
comp
- the component to be removed
-
layoutContainer
Lays out the specified container.- Specified by:
layoutContainer
in interfaceLayoutManager
- Parameters:
parent
- the container to be laid out
-
minimumLayoutSize
Calculates the minimum size dimensions for the specified container, given the components it contains.- Specified by:
minimumLayoutSize
in interfaceLayoutManager
- Parameters:
parent
- the component to be laid out- See Also:
-
preferredLayoutSize
Calculates the preferred size dimensions for the specified container, given the components it contains.- Specified by:
preferredLayoutSize
in interfaceLayoutManager
- Parameters:
parent
- the container to be laid out- See Also:
-
maximumLayoutSize
Calculates the maximum size dimensions for the specified container, given the components it contains.- Specified by:
maximumLayoutSize
in interfaceLayoutManager2
- See Also:
-
cell
-
cell
-
cell
-
toString
-