Class UIGridLayout
public class UIGridLayout extends UILayoutManager
{
// Constructors
public UIGridLayout(int rows, int cols);
public UIGridLayout(int rows, int cols, int hgap, int vgap);
// Methods
public boolean continueInvalidate(IUIContainer parent,
IUIComponent check);
public Dimension getMinimumSize(IUIContainer parent);
public Dimension getPreferredSize(IUIContainer parent);
public boolean isOverlapping();
public void layout(IUIContainer parent, Rectangle bounds);
public IUIComponent navigate(IUIContainer parent,
IUIComponent comp, int dir, boolean keyable);
}
This class implements an extended grid layout manager. UIGridLayout lays out components in a two-dimensional grid, similar to the AWT GridLayout class. The container is divided into rows and columns, where each component has the same width and height.
UILayoutManager
|
+--UIGridLayout
public UIGridLayout(int rows, int cols);
Creates a grid layout manager using the specified number of rows and columns.
Parameter | Description |
rows
| The number of rows in the grid. If zero, the grid consists of one column, and the number of rows is determined from the number of components.
|
cols
| The number of columns in the grid. If zero, the grid consists of one row, and the number of columns is determined from the number of components.
|
Remarks:
By default, the horizontal and vertical gaps (used for spacing between components) are 0 pixels each.
public UIGridLayout(int rows, int cols, int hgap, int vgap);
Creates a grid layout manager using the specified number of rows and columns, and the specified horizontal and vertical gaps.
Parameter | Description |
rows
| The number of rows in the grid. If zero, the grid consists of one column, and the number of rows is determined from the number of components.
|
cols
| The number of columns in the grid. If zero, the grid consists of one row, and the number of columns is determined from the number of components.
|
hgap
| The number of pixels used for horizontal spacing between components.
|
vgap
| The number of pixels used for vertical spacing between components.
|
public boolean continueInvalidate(IUIContainer parent, IUIComponent check);
Determines whether the container should be invalidated when the specified child component is invalidated.
Return Value:
Returns false, indicating the container should not be invalidated.
Parameter | Description |
parent
| The container of the component.
|
check
| The component being invalidated.
|
Overrides:
continueInvalidate(IUIContainer,IUIComponent) in UILayoutManager.
public Dimension getMinimumSize(IUIContainer parent);
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 |
parent
| The container of the components.
|
Remarks:
This method is called by the container's getMinimumSize method. The width of the returned Dimension object is the largest of the widths of each row. The width of each row is the sum of the minimum widths of the components in the row, plus the horizontal gaps around components.
Similarly, the returned Dimension object's height is the largest of the heights of each column. The height of each column is the sum of the minimum heights of the components in the column, plus the vertical gaps around components.
Overrides:
getMinimumSize(IUIContainer) in UILayoutManager.
See Also: getPreferredSize
public Dimension getPreferredSize(IUIContainer parent);
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 |
parent
| The container of the components.
|
Remarks:
This method is called by the container's getPreferredSize method. The width of the returned Dimension object is the largest of the widths of each row. The width of each row is the sum of the preferred widths of the components in the row, plus the horizontal gaps around components.
Similarly, the returned Dimension object's height is the largest of the heights of each column. The height of each column is the sum of the preferred heights of the components in the column, plus the vertical gaps around components.
Overrides:
getPreferredSize(IUIContainer) in UILayoutManager.
See Also: getMinimumSize
public boolean isOverlapping();
Determines if the layout manager lays out its children so that they overlap either completely or partially; otherwise, false. Returning false also means that only the sibling floater window, if one exists, needs to be clipped by the manager.
Return Value:
Returns true if the children overlap; otherwise, returns false. (The default is true.)
Overrides:
isOverlapping() in UILayoutManager.
public void layout(IUIContainer parent, Rectangle bounds);
Lays out the components in the specified container.
Return Value:
No return value.
Parameter | Description |
parent
| The container being laid out.
|
bounds
| The bounding rectangle in which to lay out the components.
|
Remarks:
This method is called by the container's layout method. layout divides the space in the bounding rectangle equally into rows and columns. This grid is then filled by row. Each component has the same width and height, and is separated by the horizontal and vertical gaps.
Overrides:
layout(IUIContainer,Rectangle) in UILayoutManager.
public IUIComponent navigate(IUIContainer parent, 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 |
parent
| 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.