|
ProgramixGenericLib v5.0.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.programix.gui.layout.AbstractTableLayout
com.programix.gui.layout.AnchorTableLayout
com.programix.gui.layout.StackLayout
public class StackLayout
Lays out components in a vertical stack (single column). Each component added gets its preferred height. The row gap specifies how many pixels are between each row in the stack (the inherited column gap has no effect on this layout as there is always only one column). The border gap specifies the distance between the laid out components and the container's own border (if any).
The AnchorPoint specified for the layout manager indicates where the
contents of the container should be placed if there is extra room.
See AbstractTableLayout.getAnchorPoint(), AbstractTableLayout.setAnchorPoint(com.programix.gui.AnchorPoint), and the
AnchorPoint that may be specified during construction.
When components are added to this container, an optional constraint
can be specified for each. If no constraint is specified (or if null
is used as the constraint), the default of AnchorPoint.CENTER
will be used.

public static JPanel createBasicDemoPane() {
JPanel basicStack = new JPanel(new StackLayout());
basicStack.setBorder(
BorderFactory.createMatteBorder(10, 10, 10, 10, Color.BLUE));
basicStack.add(makeLabel("apple", Color.RED));
basicStack.add(makeLabel("banana", Color.YELLOW));
basicStack.add(makeLabel("cherry", Color.GREEN));
basicStack.add(makeLabel("grapefruit", Color.MAGENTA));
basicStack.add(makeLabel("pear", Color.ORANGE));
basicStack.add(makeLabel("watermelon", Color.CYAN));
return basicStack;
}
public static JLabel makeLabel(String text, Color bgColor) {
JLabel label = new JLabel(text, JLabel.CENTER);
label.setOpaque(true);
label.setBackground(bgColor);
label.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
return label;
}

StackLayout stackLayout = new StackLayout(AnchorPoint.TOP_FLEX_WIDTH);
JPanel anotherStack = new JPanel(stackLayout);
anotherStack.setBorder(
BorderFactory.createMatteBorder(10, 10, 10, 10, Color.BLUE));
anotherStack.add(
makeLabel("apple", Color.RED), AnchorPoint.WEST);
anotherStack.add(
makeLabel("banana", Color.YELLOW), AnchorPoint.CENTER);
anotherStack.add(
makeLabel("cherry", Color.GREEN), AnchorPoint.EAST);
anotherStack.add(makeLabel("grapefruit", Color.MAGENTA));
anotherStack.add(
makeLabel("pear", Color.ORANGE), AnchorPoint.CENTER_FLEX_WIDTH);
anotherStack.add(makeLabel("watermelon", Color.CYAN));

StackLayout stackLayout = new StackLayout(AnchorPoint.TOP_FLEX_WIDTH);
stackLayout.setColumnAnchorPoint(0, AnchorPoint.WEST);
JPanel anotherStack = new JPanel(stackLayout);
anotherStack.setBorder(
BorderFactory.createMatteBorder(10, 10, 10, 10, Color.BLUE));
anotherStack.add(
makeLabel("apple", Color.RED), AnchorPoint.WEST);
anotherStack.add(
makeLabel("banana", Color.YELLOW), AnchorPoint.CENTER);
anotherStack.add(
makeLabel("cherry", Color.GREEN), AnchorPoint.EAST);
anotherStack.add(makeLabel("grapefruit", Color.MAGENTA));
anotherStack.add(
makeLabel("pear", Color.ORANGE), AnchorPoint.CENTER_FLEX_WIDTH);
anotherStack.add(makeLabel("watermelon", Color.CYAN));
AnchorTableLayout,
FormLayout,
ColumnButtonLayout,
RowButtonLayout,
ShelfLayout,
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.programix.gui.layout.AnchorTableLayout |
|---|
AnchorTableLayout.AnchorTableCellData |
| Nested classes/interfaces inherited from class com.programix.gui.layout.AbstractTableLayout |
|---|
AbstractTableLayout.CellData |
| Field Summary |
|---|
| Fields inherited from class com.programix.gui.layout.AbstractTableLayout |
|---|
anchorPoint, borderGap, colGap, columnCoordinator, DEFAULT_ANCHOR_POINT, DEFAULT_BORDER_GAP, DEFAULT_COL_GAP, DEFAULT_ROW_GAP, ignoreInvisibleComponents, rowGap |
| Constructor Summary | |
|---|---|
StackLayout()
Creates a single column (stack) layout. |
|
StackLayout(AnchorPoint anchorPoint)
Creates a single column (stack) layout. |
|
StackLayout(int borderGap)
Creates a single column (stack) layout. |
|
StackLayout(int rowGap,
int borderGap)
Creates a single column (stack) layout. |
|
StackLayout(int rowGap,
int borderGap,
AnchorPoint anchorPoint)
Creates a single column (stack) layout. |
|
| Method Summary | |
|---|---|
void |
setColumnCount(int columnCount)
It is meaningless to set this to anything other than 1 as this layout manager always has exactly one column. |
| Methods inherited from class com.programix.gui.layout.AnchorTableLayout |
|---|
addLayoutComponent, createCellData, getColumnAnchorPoint, getColumnCount, getColumnHeaderAnchorPoint, getLayoutAlignmentX, getLayoutAlignmentY, invalidateLayout, maximumLayoutSize, removeLayoutComponent, setColumnAnchorPoint, setColumnHeaderAnchorPoint |
| Methods inherited from class com.programix.gui.layout.AbstractTableLayout |
|---|
addLayoutComponent, getAnchorPoint, getBorderGap, getColumnCoordinator, getColumnGap, getRowGap, isIgnoreInvisibleComponents, layoutContainer, minimumLayoutSize, preferredLayoutSize, setAnchorPoint, setBorderGap, setColumnCoordinator, setColumnGap, setIgnoreInvisibleComponents, setRowGap |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.awt.LayoutManager |
|---|
addLayoutComponent, layoutContainer, minimumLayoutSize, preferredLayoutSize |
| Constructor Detail |
|---|
public StackLayout(int rowGap,
int borderGap,
AnchorPoint anchorPoint)
rowGap - space between rows.
See setRowGap().borderGap - space around the outside of the column.
See setBorderGap().anchorPoint - region to anchor to when there is extra space
See setAnchorPoint().
public StackLayout(int rowGap,
int borderGap)
DEFAULT_ANCHOR_POINT.
rowGap - space between rows.
See setRowGap().borderGap - space around the outside of the form.
See setBorderGap().public StackLayout(AnchorPoint anchorPoint)
DEFAULT_ROW_GAP.
Uses DEFAULT_BORDER_GAP.
anchorPoint - region to anchor to when there is extra space
See setAnchorPoint().public StackLayout(int borderGap)
DEFAULT_ROW_GAP.
Uses DEFAULT_ANCHOR_POINT.
borderGap - space around the outside of the form.
See setBorderGap().public StackLayout()
DEFAULT_ROW_GAP.
Uses DEFAULT_BORDER_GAP.
Uses DEFAULT_ANCHOR_POINT.
| Method Detail |
|---|
public final void setColumnCount(int columnCount)
setColumnCount in class AnchorTableLayoutcolumnCount - new number of columns; must be at least one.
If this is the same as the current number of columns, this method
call does nothing.
|
ProgramixGenericLib v5.0.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||