Class UIFlowLayout
public class UIFlowLayout extends UILayoutManager
{
// Fields
public static final int CENTER;
public static final int LEFT;
public static final int RIGHT;
// Constructors
public UIFlowLayout();
public UIFlowLayout(int align);
public UIFlowLayout(int align, int hgap, int vgap);
// Methods
public int getAlignment();
public Dimension getMinimumSize(IUIContainer target);
public Dimension getPreferredSize(IUIContainer target);
public boolean isHeightRelative();
public boolean isOverlapping();
public boolean isWidthRelative();
public boolean isWrap();
public void layout(IUIContainer target, Rectangle bounds);
public IUIComponent navigate(IUIContainer cont,
IUIComponent comp, int dir, boolean keyable);
public void setAlignment(int alignment);
public void setWrap(boolean b);
}
This class implements an extended flow layout manager. UIFlowLayout lays out components from left to right by row, similar to the AWT FlowLayout class. By default, the components are centered horizontally within the container. UIFlowLayout is the default layout manager for UIPanel.
UILayoutManager
|
+--UIFlowLayout
public UIFlowLayout();
Creates a flow layout manager.
Remarks:
By default, the horizontal and vertical gaps (used for spacing around the container's components) are defined to be 5 pixels each. The components are centered horizontally within the container.
public UIFlowLayout(int align);
Creates a flow layout manager with the specified horizontal alignment.
Parameter | Description |
align
| The horizontal alignment for the components in the container. Possible values include LEFT, CENTER, or RIGHT.
|
Remarks:
By default, the horizontal and vertical gaps (used for spacing between components) are 5 pixels each.
public UIFlowLayout(int align, int hgap, int vgap);
Creates a flow layout manager with the specified horizontal alignment.
Parameter | Description |
align
| The horizontal alignment for the components in the container. Possible values include LEFT, CENTER, or RIGHT.
|
hgap
| The number of pixels used for horizontal spacing between the components.
|
vgap
| The number of pixels used for vertical spacing above and below the components.
|
public int getAlignment();
Retrieves the current layout alignment.
Return Value:
Returns an integer indicating the horizontal alignment of the container's components. For a list of possible values, see setAlignment.
public Dimension getMinimumSize(IUIContainer target);
Determines the minimum dimensions (in pixels) needed to lay out the components in the specified container.
Return Value:
Returns a Dimension object containing the minimum layout size.
Parameter | Description |
target
| The container of the components.
|
Remarks:
getMinimumSize determines the minimum size as if the components were laid in a single row. The width of the returned Dimension object is the sum of the minimum widths of each component, and the horizontal gaps between components. The Dimension object's height is the largest minimum height of the components, plus the vertical gaps.
Overrides:
getMinimumSize(IUIContainer) in UILayoutManager.
See Also: getPreferredSize, layout
public Dimension getPreferredSize(IUIContainer target);
Determines the preferred dimensions (in pixels) for laying out the child components in the specified container.
Return Value:
Returns a Dimension object containing the preferred layout size.
Parameter | Description |
target
| The container of the components.
|
Remarks:
getPreferredSize determines the preferred size as if the components were laid in a single row. The width of the returned Dimension object is the sum of the preferred widths of each component, the horizontal gaps between components. The Dimension object's height is the largest preferred height of the components, plus the vertical gaps.
Overrides:
getPreferredSize(IUIContainer) in UILayoutManager.
See Also: getMinimumSize, layout
public boolean isHeightRelative();
Determines if this layout manager uses the height of the container to lay out its children.
Return Value:
Returns true when not in wrap mode; otherwise, returns false. (The default is true.) Returning false also means that the container's layout method doesn't need to be called on a horizontal resizing.
Overrides:
isHeightRelative() in UILayoutManager.
See Also: isWidthRelative, setWrap, isWrap
public boolean isOverlapping();
Determines if this layout manager lays out its children so that they overlap either completely or partially.
Return Value:
Returns true if the children overlap; otherwise, returns false. (The default is false.) Returning false also means that only the sibling floater window, if one exists, needs to be clipped by the manager.
Overrides:
isOverlapping() in UILayoutManager.
public boolean isWidthRelative();
Determines if this layout manager uses the width of the container to lay out its children. Returning false also means that the container's layout method doesn't need to be called on a vertical resizing.
Return Value:
Returns true when not LEFT aligned; otherwise, returns false.
Overrides:
isWidthRelative() in UILayoutManager.
See Also: isHeightRelative
public boolean isWrap();
Retrieves the layout wrap state. The wrap state can be either true or false. When set to true, the layout will use more than one line.
Return Value:
Returns the wrap state, either true or false, depending on how it was set.
See Also: setWrap
public void layout(IUIContainer target, Rectangle bounds);
Lays out the components in the specified container.
Return Value:
No return value.
Parameter | Description |
target
| The container being laid out.
|
bounds
| The bounding rectangle in which to lay out the components.
|
Remarks:
The components are laid from left to right, using the horizontal gap for spacing between each component. The width of each component is its preferred width, and if necessary, the layout flows to multiple rows. (The vertical gap is used for spacing between rows.) The height of a component is the largest preferred height of all components in the row.
Each row of components is horizontally aligned within the bounding rectangle, according to the current layout alignment (LEFT, CENTER, or RIGHT).
Overrides:
layout(IUIContainer,Rectangle) in UILayoutManager.
public IUIComponent navigate(IUIContainer cont, IUIComponent comp, int dir,
boolean keyable);
Navigates from the specified component to another component in the specified direction.
Return Value:
Returns the component navigated to (if a component in the specified direction exists); otherwise, returns null.
Parameter | Description |
cont
| The container where the navigation is occurring.
|
comp
| The component to navigate from.
|
dir
| The navigation direction. Specify one of the NAVDIR values defined in the IUIAccessible interface.
|
keyable
| If true, only components that are able to receive keyboard input can be navigated to; otherwise, all components can be navigated to.
|
Remarks:
This method handles keyboard navigation in the container. When a component in the container has focus and a key is pressed, navigate is called to move focus to another item in the container. The following table shows the keys that have corresponding IUIAccessible directions.
Overrides:
navigate(IUIContainer,IUIComponent,int,boolean) in UILayoutManager.
public void setAlignment(int alignment);
Sets the layout alignment.
Return Value:
No return value.
Parameter | Description |
alignment
| The horizontal alignment for the container's components. Possible values include LEFT, CENTER, or RIGHT.
|
See Also: getAlignment
public void setWrap(boolean b);
Sets the layout to allow wrapping of components.
Return Value:
No return value.
Parameter | Description |
b
| Can be either true or false, depending on whether the state is being set to wrappable or non-wrappable.
|
See Also: isWrap
- CENTER
- Specifies that the layout manager will horizontally center the components in the container.
- LEFT
- Specifies that the layout manager will left-align the components in the container.
- RIGHT
- Specifies that the layout manager will right-align the components in the container.