org.bounce
Class FormLayout
- java.lang.Object
-
- org.bounce.FormLayout
-
- All Implemented Interfaces:
- java.awt.LayoutManager, java.awt.LayoutManager2
public class FormLayout extends java.lang.Object implements java.awt.LayoutManager2A Layout manager that can be used to layout 2 columns of components. The alignment and fill type of the columns can be set by using the FormConstraint class.
A couple of predefined FormConstraint objects have been defined:- LEFT, Places the component in the left column of the form.
- RIGHT, Places the component in the right column of the form.
- RIGHT_FILL, Places the component in the right column of the form and fills the component so it takes up the maximum horizontal space.
- FULL, The component takes up both the left and right column, and is aligned to the left of the row.
- FULL_FILL, The component takes up both the left and right column, and is set to fill the whole width of the row.
- Alignment of components that fill the height or width completely already will not result in a visible change. Ie. the full positioned component will never react to a Vertical alignment setting.
- The fill method will only change the horizontal appearance.
- Components that are bigger than the available width/height will be LEFT aligned.
-
-
Field Summary
Fields Modifier and Type Field and Description static FormConstraintsFULLA constraint that allows the component to use the total width of the form.static FormConstraintsFULL_FILLA constraint that allows the component to use the total width of the form and resizes the component to fill the whole width.static FormConstraintsLEFTA constraint that adds the component to the left side of the form.static FormConstraintsRIGHTA constraint that adds the component to the right side of the form.static FormConstraintsRIGHT_FILLA constraint that adds the component to the right side of the form and resizes the component to fill the whole available width.
-
Constructor Summary
Constructors Constructor and Description FormLayout()Constructs a default FormLayout without any horizontal or vertical gaps.FormLayout(int hGap, int vGap)Constructs a FormLayout with the specified horizontal and vertical gap.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddLayoutComponent(java.awt.Component component, java.lang.Object constraints)Adds the specified component to the layout, using the specified constraint object.voidaddLayoutComponent(java.lang.String name, java.awt.Component comp)Not used, components cannot be added without a constraint.intgetHgap()Returns the horizontal gap between the left column and the right column.floatgetLayoutAlignmentX(java.awt.Container target)Returns the alignment along the x axis.floatgetLayoutAlignmentY(java.awt.Container target)Returns the alignment along the y axis.intgetVgap()Returns the vertical gap between the rows.voidinvalidateLayout(java.awt.Container target)Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.voidlayoutContainer(java.awt.Container parent)Lays out the components on the specified container.java.awt.DimensionmaximumLayoutSize(java.awt.Container target)Returns the maximum size of this component.java.awt.DimensionminimumLayoutSize(java.awt.Container parent)Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.java.awt.DimensionpreferredLayoutSize(java.awt.Container parent)Calculates the preferred size dimensions for the specified container given the components in the specified parent container.voidremoveLayoutComponent(java.awt.Component component)Removes the specified component and constraints from the layout.voidsetConstraints(java.awt.Component component, java.lang.Object constraint)Adds the specified component to the layout, using the specified constraint object.voidsetHgap(int hGap)Sets the horizontal gap between the left column and the right column.voidsetVgap(int vGap)Returns the vertical gap between the rows.
-
-
-
Field Detail
-
LEFT
public static final FormConstraints LEFT
A constraint that adds the component to the left side of the form.
-
RIGHT
public static final FormConstraints RIGHT
A constraint that adds the component to the right side of the form.
-
RIGHT_FILL
public static final FormConstraints RIGHT_FILL
A constraint that adds the component to the right side of the form and resizes the component to fill the whole available width.
-
FULL
public static final FormConstraints FULL
A constraint that allows the component to use the total width of the form.
-
FULL_FILL
public static final FormConstraints FULL_FILL
A constraint that allows the component to use the total width of the form and resizes the component to fill the whole width.
-
-
Constructor Detail
-
FormLayout
public FormLayout()
Constructs a default FormLayout without any horizontal or vertical gaps.
-
FormLayout
public FormLayout(int hGap, int vGap)Constructs a FormLayout with the specified horizontal and vertical gap.- Parameters:
hGap- the horizontal gap between the left and right components.vGap- the vertical gap between the rows.
-
-
Method Detail
-
getHgap
public int getHgap()
Returns the horizontal gap between the left column and the right column.- Returns:
- the horizontal gap.
-
setHgap
public void setHgap(int hGap)
Sets the horizontal gap between the left column and the right column.- Parameters:
hGap- the horizontal gap between the columns
-
getVgap
public int getVgap()
Returns the vertical gap between the rows.- Returns:
- the vertical gap.
-
setVgap
public void setVgap(int vGap)
Returns the vertical gap between the rows.- Parameters:
vGap- the vertical gap between the rows
-
setConstraints
public void setConstraints(java.awt.Component component, java.lang.Object constraint)Adds the specified component to the layout, using the specified constraint object. For Form layouts, the constraint must be an instance of the FormConstraints class.- Parameters:
component- the component added to the parent container.constraint- the constraint for the added component.
-
removeLayoutComponent
public void removeLayoutComponent(java.awt.Component component)
Removes the specified component and constraints from the layout.- Specified by:
removeLayoutComponentin interfacejava.awt.LayoutManager- Parameters:
component- the component to be removed
-
preferredLayoutSize
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Calculates the preferred size dimensions for the specified container given the components in the specified parent container.- Specified by:
preferredLayoutSizein interfacejava.awt.LayoutManager- Parameters:
parent- the component to be laid out.- Returns:
- the preferred size of the layout.
-
minimumLayoutSize
public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.- Specified by:
minimumLayoutSizein interfacejava.awt.LayoutManager- Parameters:
parent- the component to be laid out- Returns:
- the minimum size of the layout.
-
layoutContainer
public void layoutContainer(java.awt.Container parent)
Lays out the components on the specified container.- Specified by:
layoutContainerin interfacejava.awt.LayoutManager- Parameters:
parent- the component which needs to be laid out
-
addLayoutComponent
public void addLayoutComponent(java.awt.Component component, java.lang.Object constraints)Adds the specified component to the layout, using the specified constraint object.- Specified by:
addLayoutComponentin interfacejava.awt.LayoutManager2- Parameters:
component- the component to be addedconstraints- where/how the component is added to the layout.
-
maximumLayoutSize
public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
Returns the maximum size of this component.- Specified by:
maximumLayoutSizein interfacejava.awt.LayoutManager2- Parameters:
target- the component to be laid out- Returns:
- the maximum size of the layout.
- See Also:
Component.getMinimumSize(),Component.getPreferredSize()
-
getLayoutAlignmentX
public float getLayoutAlignmentX(java.awt.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 interfacejava.awt.LayoutManager2- Parameters:
target- the container to calculate X alignment for.- Returns:
- the X alignment.
-
getLayoutAlignmentY
public float getLayoutAlignmentY(java.awt.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 interfacejava.awt.LayoutManager2- Parameters:
target- the container to calculate Y alignment for.- Returns:
- the Y alignment.
-
invalidateLayout
public void invalidateLayout(java.awt.Container target)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.- Specified by:
invalidateLayoutin interfacejava.awt.LayoutManager2- Parameters:
target- the container.
-
addLayoutComponent
public void addLayoutComponent(java.lang.String name, java.awt.Component comp)Not used, components cannot be added without a constraint.- Specified by:
addLayoutComponentin interfacejava.awt.LayoutManager- Parameters:
name- the component name.comp- the component.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG