Package com.bc.ceres.swing
Class TableLayout
- java.lang.Object
-
- com.bc.ceres.swing.TableLayout
-
- All Implemented Interfaces:
LayoutManager,LayoutManager2
public class TableLayout extends Object implements 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
GridBagLayoutmanager, however clients don't have to deal withGridBagConstraints. 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>().
fillandanchorparameter values.Any parameter settings may be removed from the layout by passing
nullas value.Components are added to their container using a
cell(row, col)orcell(row, col, rowspan, colspan)constraint, for example:panel.add(new JLabel("Iterations:"), TableLayout.cell(0, 3));
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTableLayout.AnchorThis parameter is used when the component's display area is larger than the component's requested size.static classTableLayout.Cellstatic classTableLayout.FillThis parameter is used when the component is smaller than its display area.
-
Constructor Summary
Constructors Constructor Description TableLayout()TableLayout(int columnCount)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLayoutComponent(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)ComponentcreateHorizontalSpacer()ComponentcreateVerticalSpacer()intgetColumnCount()floatgetLayoutAlignmentX(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.DimensionmaximumLayoutSize(Container parent)Calculates the maximum size dimensions for the specified container, given the components it contains.DimensionminimumLayoutSize(Container parent)Calculates the minimum size dimensions for the specified container, given the components it contains.DimensionpreferredLayoutSize(Container parent)Calculates the preferred size dimensions for the specified container, given the components it contains.voidremoveLayoutComponent(Component comp)Removes 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)StringtoString()
-
-
-
Method Detail
-
getColumnCount
public int getColumnCount()
-
setColumnCount
public void setColumnCount(int columnCount)
-
setCellColspan
public void setCellColspan(int row, int col, Integer colspan)
-
setCellRowspan
public void setCellRowspan(int row, int col, Integer rowspan)
-
setTablePadding
public void setTablePadding(int hpadding, int vpadding)
-
setTablePadding
public void setTablePadding(Insets insets)
-
setRowPadding
public void setRowPadding(int row, Insets insets)
-
setColumnPadding
public void setColumnPadding(int col, Insets insets)
-
setCellPadding
public void setCellPadding(int row, int col, Insets insets)
-
setTableWeightX
public void setTableWeightX(Double weightx)
-
setRowWeightX
public void setRowWeightX(int row, Double weightx)
-
setColumnWeightX
public void setColumnWeightX(int col, Double weightx)
-
setCellWeightX
public void setCellWeightX(int row, int col, Double weightx)
-
setTableWeightY
public void setTableWeightY(Double weighty)
-
setRowWeightY
public void setRowWeightY(int row, Double weighty)
-
setColumnWeightY
public void setColumnWeightY(int col, Double weighty)
-
setCellWeightY
public void setCellWeightY(int row, int col, Double weighty)
-
setTableFill
public void setTableFill(TableLayout.Fill fill)
-
setRowFill
public void setRowFill(int row, TableLayout.Fill fill)
-
setColumnFill
public void setColumnFill(int col, TableLayout.Fill fill)
-
setCellFill
public void setCellFill(int row, int col, TableLayout.Fill fill)
-
setTableAnchor
public void setTableAnchor(TableLayout.Anchor anchor)
-
setRowAnchor
public void setRowAnchor(int row, TableLayout.Anchor anchor)
-
setColumnAnchor
public void setColumnAnchor(int col, TableLayout.Anchor anchor)
-
setCellAnchor
public void setCellAnchor(int row, int col, TableLayout.Anchor anchor)
-
createHorizontalSpacer
public Component createHorizontalSpacer()
-
createVerticalSpacer
public Component createVerticalSpacer()
-
getLayoutAlignmentX
public float getLayoutAlignmentX(Container target)
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
public float getLayoutAlignmentY(Container target)
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
public void invalidateLayout(Container target)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.- Specified by:
invalidateLayoutin interfaceLayoutManager2
-
addLayoutComponent
public void addLayoutComponent(Component comp, Object constraints)
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
public void addLayoutComponent(String name, Component comp)
Has no effect, since this layout manager does not use a per-component string.- Specified by:
addLayoutComponentin interfaceLayoutManager
-
removeLayoutComponent
public void removeLayoutComponent(Component comp)
Removes the specified component from the layout.- Specified by:
removeLayoutComponentin interfaceLayoutManager- Parameters:
comp- the component to be removed
-
layoutContainer
public void layoutContainer(Container parent)
Lays out the specified container.- Specified by:
layoutContainerin interfaceLayoutManager- Parameters:
parent- the container to be laid out
-
minimumLayoutSize
public Dimension minimumLayoutSize(Container parent)
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(java.awt.Container)
-
preferredLayoutSize
public Dimension preferredLayoutSize(Container parent)
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:
minimumLayoutSize(java.awt.Container)
-
maximumLayoutSize
public Dimension maximumLayoutSize(Container parent)
Calculates the maximum size dimensions for the specified container, given the components it contains.- Specified by:
maximumLayoutSizein interfaceLayoutManager2- See Also:
Component.getMaximumSize(),LayoutManager
-
cell
public static TableLayout.Cell cell()
-
cell
public static TableLayout.Cell cell(int row, int col)
-
cell
public static TableLayout.Cell cell(int row, int col, int rowspan, int colspan)
-
-