|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.nasa.gsfc.drl.rtstps.library.layout.ListLayout
public class ListLayout
This class is a layout manager. It arranges components in a vertical list similar to a vertical Box. Unlike boxes and BoxLayout however, you may specify vertical gaps and indentations. It also grows and shrinks differently.
You may set a vertical gap, which is a mandatory spacing between components. The default is 0 pixels.
You may add an indentation as a constraint (Integer(pixels)) when you add a component to a container. ListLayout will then indent the component from the left margin. ListLayout contains a static TAB=20 pixels and TABTAB=40 for your convenience.
If you do not add glue to the container, then each component is given a cell that is proportional to its preferred size. It grows to fill its cell unless the cell is larger than the component's maximum size. In that case, the manager uses its own x and y alignments (not the component's) to place the component within the cell. By default, components are vertically centered and left-justified. (x-alignment = 0f, y-alignment = 0.5f)
You may add Box's filler components. If you add glue, then the glue grabs all extra space, and components grow no bigger than their preferred sizes.
Integer tab = new Integer(10); //10 pixels indentation Integer tab1 = new Integer(25); //25 pixels indentation int gap = 5; JPanel jp = new JPanel(new ListLayout(gap)); jp.add(comp1); //no indentation jp.add(comp2, tab); jp.add(comp2, tab2); jp.add(comp2, ListLayout.TAB); jp.add(Box.createGlue());
Field Summary | |
---|---|
private float |
_alignX
|
private float |
_alignY
|
private java.util.Vector<java.awt.Component> |
_comp
|
private int |
_gap
|
private int |
_glues
|
private java.util.Vector<java.lang.Integer> |
_indentation
|
private java.awt.Insets |
_insets
|
private int |
_maxLayoutHeight
|
private int |
_maxLayoutWidth
|
private int |
_minLayoutHeight
|
private int |
_minLayoutWidth
These layout values do not include gaps and insets. |
private int |
_prefLayoutHeight
|
private int |
_prefLayoutWidth
|
private boolean |
_valid
|
private static java.lang.Integer |
GLUE
|
private static long |
serialVersionUID
|
static java.lang.Integer |
TAB
A default indentation. |
static java.lang.Integer |
TABTAB
A default indentation. |
private static java.lang.Integer |
ZERO
|
Constructor Summary | |
---|---|
ListLayout()
Create a ListLayout object. |
|
ListLayout(int vgap)
Create a ListLayout object. |
Method Summary | |
---|---|
private int |
addHorizontalBaggage(int width,
java.awt.Insets insets)
|
void |
addLayoutComponent(java.awt.Component comp,
java.lang.Object constraint)
Add a component to the layout. |
void |
addLayoutComponent(java.lang.String name,
java.awt.Component comp)
Add a component to the layout. |
private int |
addVerticalBaggage(int height,
java.awt.Insets insets)
|
float |
getLayoutAlignmentX(java.awt.Container parent)
Get the X alignment. |
float |
getLayoutAlignmentY(java.awt.Container parent)
Get the Y alignment. |
void |
invalidateLayout(java.awt.Container parent)
Invalidate the layout. |
void |
layoutContainer(java.awt.Container parent)
Lay out the components in the container. |
private void |
locateInCell(java.awt.Component comp,
java.awt.Rectangle r)
|
java.awt.Dimension |
maximumLayoutSize(java.awt.Container parent)
Get the maximum layout size. |
java.awt.Dimension |
minimumLayoutSize(java.awt.Container parent)
Get the minimum layout size. |
java.awt.Dimension |
preferredLayoutSize(java.awt.Container parent)
Get the preferred layout size. |
void |
removeLayoutComponent(java.awt.Component comp)
Remove a component from the layout. |
void |
setGap(int gap)
Set a gap between components. |
void |
setInsets(java.awt.Insets in)
Set a blank border. |
void |
setLayoutAlignmentX(float a)
Set the X alignment. |
void |
setLayoutAlignmentY(float a)
Set the Y alignment. |
private void |
validate(java.awt.Container parent)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.Integer TAB
public static final java.lang.Integer TABTAB
private static final java.lang.Integer ZERO
private static final java.lang.Integer GLUE
private java.util.Vector<java.lang.Integer> _indentation
private java.util.Vector<java.awt.Component> _comp
private java.awt.Insets _insets
private int _glues
private int _gap
private float _alignX
private float _alignY
private boolean _valid
private int _minLayoutWidth
private int _maxLayoutWidth
private int _prefLayoutWidth
private int _minLayoutHeight
private int _maxLayoutHeight
private int _prefLayoutHeight
private static final long serialVersionUID
Constructor Detail |
---|
public ListLayout(int vgap)
vgap
- Gap in pixels between components. The gap does not affect
the border. The default is 0 pixels.public ListLayout()
Method Detail |
---|
public final void setGap(int gap)
public final void setInsets(java.awt.Insets in)
public final void setLayoutAlignmentX(float a)
public final void setLayoutAlignmentY(float a)
public final float getLayoutAlignmentX(java.awt.Container parent)
getLayoutAlignmentX
in interface java.awt.LayoutManager2
public final float getLayoutAlignmentY(java.awt.Container parent)
getLayoutAlignmentY
in interface java.awt.LayoutManager2
public final void invalidateLayout(java.awt.Container parent)
invalidateLayout
in interface java.awt.LayoutManager2
public void addLayoutComponent(java.lang.String name, java.awt.Component comp)
addLayoutComponent
in interface java.awt.LayoutManager
public void removeLayoutComponent(java.awt.Component comp)
removeLayoutComponent
in interface java.awt.LayoutManager
public void addLayoutComponent(java.awt.Component comp, java.lang.Object constraint)
addLayoutComponent
in interface java.awt.LayoutManager2
comp
- The component to be added to the layout.constraint
- This object identifies the indentation. It may be null,
in which case there is no indentation. Otherwise, it must be of
type Integer, and it is the indentation in pixels. If the
component is a Box filler type (glue, for example), the
constraint is ignored.public void layoutContainer(java.awt.Container parent)
layoutContainer
in interface java.awt.LayoutManager
public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
minimumLayoutSize
in interface java.awt.LayoutManager
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
preferredLayoutSize
in interface java.awt.LayoutManager
public final java.awt.Dimension maximumLayoutSize(java.awt.Container parent)
maximumLayoutSize
in interface java.awt.LayoutManager2
private void validate(java.awt.Container parent)
private int addHorizontalBaggage(int width, java.awt.Insets insets)
private int addVerticalBaggage(int height, java.awt.Insets insets)
private void locateInCell(java.awt.Component comp, java.awt.Rectangle r)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |