|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.itr_rescue.dataGuard.ui.VerticalFlowLayout
public class VerticalFlowLayout
VerticalFlowLayout
is a layout manager that arranges
components vertically from top to bottom. It is similar to a vertical
version of java.awt.FlowLayout
(which is strictly horizontal)
with 2 key exceptions:
It puts components in a single column, and will not
"wrap" the components when it reaches the bottom of the container.
It is far more flexible for adjusting component
alignment.
There are methods to adjust the vertical alignment and the horizontal alignment of all components in the container. The horizontal fill of the components can also be adjusted, causing them to display at their preferred widths, justifying to match the width of the widest component, or filling the width of their parent container. This makes it simple to neatly aligned layouts.
Example:
Produces something like this:VerticalFlowLayout vfLayout = new VerticalFlowLayout(); vfLayout.setHorizontalAlign(VerticalFlowLayout.LEFT); vfLayout.setVerticalAlign(VerticalFlowLayout.BOTTOM); vfLayout.setHorizontalFill(VerticalFlowLayout.NO_FILL); JPanel pane = new JPanel(vfLayout); pane.add(new JTextField(14); pane.add(new JTextField(8); pane.add(new JTextField(20);
Adjusting the layout settings can produce a very different look:
vfLayout.setHorizontalAlign(VerticalFlowLayout.CENTER); vfLayout.setVerticalAlign(VerticalFlowLayout.CENTER); vfLayout.setHorizontalFill(VerticalFlowLayout.MATCH_COMPONENTS);
Field Summary | |
---|---|
static float |
BOTTOM
Sets alignment to the bottom (value = 1). |
static float |
CENTER
Sets alignment to the center (value = 0.5). |
static int |
FILL_SPACE
Sets the horizontal fill so all components are as wide as their parent container. |
static float |
LEFT
Sets alignment to the left (value = 0). |
static int |
MATCH_COMPONENTS
Sets the horizontal fill so all components match the width of the widest component. |
static int |
NO_FILL
Sets the horizontal fill to adjust components to their preferred size. |
static float |
RIGHT
Sets alignment to the right (value = 1). |
static float |
TOP
Sets alignment to the top (value = 0). |
Constructor Summary | |
---|---|
VerticalFlowLayout()
Creates a VerticalFlowLayout with the defaults of:Horizontal alignment: CENTER Vertical alignment: TOP Horizontal gap: 5 pixels Vertical gap: 5 pixels Horizontal fill: NO_FILL |
|
VerticalFlowLayout(float horizontalAlign,
float verticalAlign)
Creates a VerticalFlowLayout with the specied horizontal
and vertical alignments and
with the defaults of:Horizontal gap: 5 pixels Vertical gap: 5 pixels Horizontal fill: NO_FILL |
|
VerticalFlowLayout(float horizontalAlign,
float verticalAlign,
int hgap,
int vgap)
Creates a VerticalFlowLayout with the specied horizontal
and vertical alignments and horizontal and vertical gaps and
with the default of:Horizontal fill: NO_FILL |
Method Summary | |
---|---|
void |
addLayoutComponent(java.lang.String name,
java.awt.Component comp)
Not implemented |
int |
getHgap()
Gets the horizontal space next to each component. |
float |
getHorizontalAlign()
Returns a float value between 0 and 1 that represents the horizontal alignment. |
int |
getHorizontalFill()
Returns the Horizontal Fill value that specifies the horizontal fill policy which determines how wide the components are. |
float |
getVerticalAlign()
Returns a float value between 0 and 1 that represents the vertical alignment. |
int |
getVgap()
Gets the vertical space between components. |
void |
layoutContainer(java.awt.Container parent)
Sets the size and location of the components within this container and displays the container using this layout. |
java.awt.Dimension |
minimumLayoutSize(java.awt.Container parent)
Determines the minimum size of the container using this Layout based on the components contained within, and the space surrounding each component. |
java.awt.Dimension |
preferredLayoutSize(java.awt.Container parent)
Determines the preferred size of the container using this Layout based on the components contained within, and the space surrounding each component. |
void |
removeLayoutComponent(java.awt.Component comp)
Not implemented |
void |
setAlignment(float horizontal,
float vertical)
Convienence method that sets both the horizontal and vertical alignments. |
void |
setHgap(int hgap)
Sets the horizontal space next to each component to the specified value. |
void |
setHorizontalAlign(float horizontalAlign)
Sets the horizontal alignment. |
void |
setHorizontalFill(int fillPolicy)
Sets the Horizontal Fill policy which determines how wide the components are. |
void |
setSpace(int hgap,
int vgap)
Sets both the horizontal and vertical space between components to the specified values. |
void |
setVerticalAlign(float verticalAlign)
Sets the vertical alignment. |
void |
setVgap(int vgap)
Sets the vertical space between components to the specified value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final float TOP
public static final float BOTTOM
public static final float CENTER
public static final float LEFT
public static final float RIGHT
public static final int NO_FILL
public static final int MATCH_COMPONENTS
public static final int FILL_SPACE
Constructor Detail |
---|
public VerticalFlowLayout()
VerticalFlowLayout
with the defaults of:
public VerticalFlowLayout(float horizontalAlign, float verticalAlign)
VerticalFlowLayout
with the specied horizontal
and vertical alignments and
with the defaults of:
horizontalAlign
- a float between 0 and 1 representing the
horizontal alignment or the constants: VerticalFlowLayout.LEFT,
VerticalFlowLayout.CENTER, VerticalFlowLayout.RIGHT.verticalAlign
- a float between 0 and 1 representing the
vertical alignment or the contstants: VerticalFlowLayout.TOP,
VerticalFlowLayout.CENTER, VerticalFlowLayout.BOTTOM.public VerticalFlowLayout(float horizontalAlign, float verticalAlign, int hgap, int vgap)
VerticalFlowLayout
with the specied horizontal
and vertical alignments and horizontal and vertical gaps and
with the default of:
horizontalAlign
- a float between 0 and 1 representing the
horizontal alignment or the constants: VerticalFlowLayout.LEFT,
VerticalFlowLayout.CENTER, VerticalFlowLayout.RIGHT.verticalAlign
- a float between 0 and 1 representing the
vertical alignment or the contstants: VerticalFlowLayout.TOP,
VerticalFlowLayout.CENTER, VerticalFlowLayout.BOTTOM.hgap
- The horizontal border size in pixels.vgap
- The vertical border size in pixels.Method Detail |
---|
public int getHgap()
public void setHgap(int hgap)
hgap
- The horizontal space size in pixels.public int getVgap()
public void setVgap(int vgap)
hgap
- The vertical space size in pixels.public void setSpace(int hgap, int vgap)
hgap
- The horizontal space size in pixels.vgap
- The vertical space size in pixels.public int getHorizontalFill()
VerticalFlowLayout.NO_FILL (component width determined by its preferred size) VerticalFlowLayout.MATCH_COMPONENTS (all components have the width of the widest component) VerticalFlowLayout.FILL_SPACE (all components are as wide as their parent container)
public void setHorizontalFill(int fillPolicy)
VerticalFlowLayout.NO_FILL (component width determined by its preferred size) VerticalFlowLayout.MATCH_COMPONENTS (all components have the width of the widest component) VerticalFlowLayout.FILL_SPACE (all components are as wide as their parent container)
fillPolicy
- an int matching one of the Fill values described above.public float getHorizontalAlign()
public void setHorizontalAlign(float horizontalAlign)
VerticalFlowLayout.LEFT VerticalFlowLayout.CENTER VerticalFlowLayout.RIGHT
horizontalAlign
- a float between 0 and 1.public float getVerticalAlign()
public void setVerticalAlign(float verticalAlign)
VerticalFlowLayout.TOP VerticalFlowLayout.CENTER VerticalFlowLayout.BOTTOM
verticalAlign
- a float between 0 and 1.public void setAlignment(float horizontal, float vertical)
setHorizontalAlign(horizontal);
setVerticalAlign(vertical);
horizontal
- a float between 0 and 1.vertical
- a float between 0 and 1.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 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
preferredLayoutSize
in interface java.awt.LayoutManager
parent
- the container in which to do the layout.
public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
minimumLayoutSize
in interface java.awt.LayoutManager
parent
- the container in which to do the layout.
public void layoutContainer(java.awt.Container parent)
Sets the size and location of the components within this container and displays the container using this layout.
This method lays out the components in a single vertical column from top to bottom.
layoutContainer
in interface java.awt.LayoutManager
parent
- The container in which to do the layout.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |