Class UIFixedFlowLayout
public class UIFixedFlowLayout extends UILayoutManager
{
// Fields
public static final int CENTER;
public static final int LEFT;
public static final int RIGHT;
// Constructors
public UIFixedFlowLayout();
public UIFixedFlowLayout(int hgap, int vgap);
public UIFixedFlowLayout(int hgap, int vgap, int alignment);
// Methods
protected Dimension computeUnitDimension(IUIContainer target,
boolean min);
public int getAlignment();
public Dimension getMinimumSize(IUIContainer target);
public Dimension getPreferredSize(IUIContainer target);
public boolean isOverlapping();
public boolean isWidthRelative();
public void layout(IUIContainer target, Rectangle bounds);
public IUIComponent navigate(IUIContainer cont,
IUIComponent comp, int dir, boolean keyable);
public void setAlignment(int alignment);
}
This class implements a fixed-width flow layout manager. UIFixedFlowLayout lays out components by row, using a fixed width for each component. The fixed width is the largest of the preferred widths of each component.
UIFixedFlowLayout is the default layout manager for UIBand.
UILayoutManager
|
+--UIFixedFlowLayout
public UIFixedFlowLayout();
Creates a fixed-width flow layout manager.
Remarks:
By default, the horizontal and vertical gaps (used for spacing around the container's components) are 5 pixels each. The components are left-aligned within the container.
public UIFixedFlowLayout(int hgap, int vgap);
Creates a fixed-width flow layout manager with the specified horizontal and vertical gaps.
Parameter | Description |
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.
|
Remarks:
By default, the components are left-aligned within the container.
public UIFixedFlowLayout(int hgap, int vgap, int alignment);
Creates a fixed-width flow layout manager with the specified alignment, and horizontal and vertical gaps.
Parameter | Description |
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.
|
alignment
| The horizontal alignment for the components in the container. Possible values include LEFT, CENTER, or RIGHT.
|
protected Dimension computeUnitDimension(IUIContainer target, boolean min);
Returns the maximum size of the biggest component's width and height (in pixels).
Return Value:
Returns a dimension object that contains the biggest component's width and height.
Parameter | Description |
target
| The container that holds the components.
|
min
| The minimum size.
|
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 child 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 the fixed widths of the remaining components, and the horizontal gaps between components. The fixed width is defined to be the largest of the minimum widths of the components. The Dimension object's height is the sum of the largest minimum height of all components, and 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 the fixed widths of the remaining components and the horizontal gaps between components. The fixed width is defined to be the largest of the preferred widths of the components. The Dimension object's height is the sum of the largest preferred height of all components, and the vertical gaps.
Overrides:
getPreferredSize(IUIContainer) in UILayoutManager.
See Also: getMinimumSize, layout
public boolean isOverlapping();
Determines if the container allows its children to overlap partially or completely.
Return Value:
Returns false, by default.
Overrides:
isOverlapping() in UILayoutManager.
public boolean isWidthRelative();
Determines if this layout manager uses the width of the container to lay out its children.
Return Value:
Returns true if the alignment is not LEFT; 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 vertical resizing.
Overrides:
isWidthRelative() in UILayoutManager.
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 child components are laid out using the horizontal gap for spacing between each component. The width of these components is fixed to be the largest of their preferred widths. The height is the largest of the preferred heights. If necessary, the layout flows to multiple rows. (The vertical gap is used for spacing between rows.)
Each row of components is horizontally aligned within the container's available space, according to the current layout alignment (LEFT, CENTER, or RIGHT). The available space is determined from the container's size minus its horizontal and vertical gaps.
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 tab component to navigate from.
|
dir
| The navigation direction. Specify one of the following values defined in IUIAccessible:
|
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
- 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.