Class PercentLayout
java.lang.Object
se.datadosen.component.buttonbar.PercentLayout
- All Implemented Interfaces:
LayoutManager,LayoutManager2
PercentLayout.
Constraint based layout which allow the space to be splitted using percentages. The following are allowed when adding components to container:
Constraint based layout which allow the space to be splitted using percentages. The following are allowed when adding components to container:
- container.add(component);
in this case, the component will be sized to its preferred size - container.add(component, "100");
in this case, the component will have a width (or height) of 100 - container.add(component, "25%");
in this case, the component will have a width (or height) of 25 % of the container width (or height)
- container.add(component, "*");
in this case, the component will take the remaining space. if several components use the "*" constraint the space will be divided among the components.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intUseful constant to layout the components horizontally (from top to bottom).static final intUseful constant to layout the components vertically (from left to right). -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new HORIZONTAL PercentLayout with a gap of 0.PercentLayout(int orientation, int gap) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLayoutComponent(Component component, Object constraints) voidaddLayoutComponent(String name, Component comp) Adds the specified component with the specified name to the layout.se.datadosen.component.buttonbar.PercentLayout.ConstraintgetConstraint(Component component) intgetGap()floatgetLayoutAlignmentX(Container target) Returns the alignment along the x axis.floatgetLayoutAlignmentY(Container target) Returns the alignment along the y axis.intvoidinvalidateLayout(Container target) Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.voidlayoutContainer(Container parent) maximumLayoutSize(Container parent) Returns the maximum size of this component.minimumLayoutSize(Container parent) Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.preferredLayoutSize(Container parent) voidRemoves the specified component from the layout.voidsetConstraint(Component component, Object constraints) voidsetGap(int gap) voidsetOrientation(int orientation)
-
Field Details
-
HORIZONTAL
public static final int HORIZONTALUseful constant to layout the components horizontally (from top to bottom).- See Also:
-
VERTICAL
public static final int VERTICALUseful constant to layout the components vertically (from left to right).- See Also:
-
-
Constructor Details
-
PercentLayout
public PercentLayout()Creates a new HORIZONTAL PercentLayout with a gap of 0. -
PercentLayout
public PercentLayout(int orientation, int gap)
-
-
Method Details
-
setGap
public void setGap(int gap) -
getGap
public int getGap() -
setOrientation
public void setOrientation(int orientation) -
getOrientation
public int getOrientation() -
getConstraint
-
setConstraint
-
addLayoutComponent
- Specified by:
addLayoutComponentin interfaceLayoutManager2
-
getLayoutAlignmentX
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
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
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.- Specified by:
invalidateLayoutin interfaceLayoutManager2
-
addLayoutComponent
Adds the specified component with the specified name to the layout.- Specified by:
addLayoutComponentin interfaceLayoutManager- Parameters:
name- the component namecomp- the component to be added
-
removeLayoutComponent
Removes the specified component from the layout.- Specified by:
removeLayoutComponentin interfaceLayoutManager- Parameters:
comp- the component ot be removed
-
minimumLayoutSize
Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.- Specified by:
minimumLayoutSizein interfaceLayoutManager- Parameters:
parent- the component to be laid out- See Also:
-
maximumLayoutSize
Returns the maximum size of this component.- Specified by:
maximumLayoutSizein interfaceLayoutManager2- See Also:
-
preferredLayoutSize
- Specified by:
preferredLayoutSizein interfaceLayoutManager
-
layoutContainer
- Specified by:
layoutContainerin interfaceLayoutManager
-