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 enumThis parameter is used when the component's display area is larger than the component's requested size.static classstatic enumThis parameter is used when the component is smaller than its display area. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLayoutComponent(Component comp, Object constraints) Adds the specified component to the layout, using the specified constraint object.voidaddLayoutComponent(String name, Component comp) Has no effect, since this layout manager does not use a per-component string.static TableLayout.Cellcell()static TableLayout.Cellcell(int row, int col) static TableLayout.Cellcell(int row, int col, int rowspan, int colspan) intfloatgetLayoutAlignmentX(Container target) Returns the alignment along the x axis.floatgetLayoutAlignmentY(Container target) Returns the alignment along the y axis.voidinvalidateLayout(Container target) Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.voidlayoutContainer(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.voidRemoves the specified component from the layout.voidsetCellAnchor(int row, int col, TableLayout.Anchor anchor) voidsetCellColspan(int row, int col, Integer colspan) voidsetCellFill(int row, int col, TableLayout.Fill fill) voidsetCellPadding(int row, int col, Insets insets) voidsetCellRowspan(int row, int col, Integer rowspan) voidsetCellWeightX(int row, int col, Double weightx) voidsetCellWeightY(int row, int col, Double weighty) voidsetColumnAnchor(int col, TableLayout.Anchor anchor) voidsetColumnCount(int columnCount) voidsetColumnFill(int col, TableLayout.Fill fill) voidsetColumnPadding(int col, Insets insets) voidsetColumnWeightX(int col, Double weightx) voidsetColumnWeightY(int col, Double weighty) voidsetRowAnchor(int row, TableLayout.Anchor anchor) voidsetRowFill(int row, TableLayout.Fill fill) voidsetRowPadding(int row, Insets insets) voidsetRowWeightX(int row, Double weightx) voidsetRowWeightY(int row, Double weighty) voidsetTableAnchor(TableLayout.Anchor anchor) voidsetTableFill(TableLayout.Fill fill) voidsetTablePadding(int hpadding, int vpadding) voidsetTablePadding(Insets insets) voidsetTableWeightX(Double weightx) voidsetTableWeightY(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:
getLayoutAlignmentXin 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:
getLayoutAlignmentYin interfaceLayoutManager2
-
invalidateLayout
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.- Specified by:
invalidateLayoutin interfaceLayoutManager2
-
addLayoutComponent
Adds the specified component to the layout, using the specified constraint object.- Specified by:
addLayoutComponentin 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:
addLayoutComponentin interfaceLayoutManager
-
removeLayoutComponent
Removes the specified component from the layout.- Specified by:
removeLayoutComponentin interfaceLayoutManager- Parameters:
comp- the component to be removed
-
layoutContainer
Lays out the specified container.- Specified by:
layoutContainerin 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:
minimumLayoutSizein 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:
preferredLayoutSizein 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:
maximumLayoutSizein interfaceLayoutManager2- See Also:
-
cell
-
cell
-
cell
-
toString
-