Class UIRowLayout
public class UIRowLayout extends UILayoutManager
{
// Constructors
public UIRowLayout(int columns);
public UIRowLayout(IUIComponent header, int columns);
public UIRowLayout(IUIComponent header, int columns, int widths);
public UIRowLayout(IUIComponent header, int columns,
int widths[]);
// Methods
public IUIComponent getComponent(IUIContainer cont, int index);
public Dimension getMinimumSize(IUIContainer parent);
public int getOrderIndex(int index);
public Dimension getPreferredSize(IUIContainer parent);
public int getWidth(int index);
public int[] getWidths();
public boolean isOverlapping();
public boolean isWidthRelative();
public void layout(IUIContainer target, Rectangle bounds);
public void moveColumn(int from, int to);
public IUIComponent navigate(IUIContainer cont,
IUIComponent comp, int dir, boolean keyable);
public void setWidth(int index, int width);
public void setWidths(int width);
public void setWidths(int widths[]);
}
This class implements a layout manager for a row of objects or columns. UIHeaderRow uses UIRowLayout for its default layout manager.
UIRowLayout maintains an index and an order for each column. When the layout manager is first created, the index of each column is defined by its initial order. The moveColumn method enables you to change the order of the columns; however, the index of each column does not change.
The following example demonstrates the moveColumn method.
// Construct a UIHeaderRow object. By default,
// UIHeaderRow uses UIRowLayout for its layout
// manager.
String s [] = { "A," "B," "C," "D" };
UIHeaderRow hr = new UIHeaderRow(s);
add(hr); // Add hr to the container.
// Initially, the columns are indexed and
// ordered as follows:
// A B C D
// index: 0 1 2 3
// order: 0 1 2 3
//
// Now retrieve the layout manager and move
// column B (index 1) to the location of
// column D (index 3).
IUILayoutManager lm = hr.getLayout();
lm.moveColumns(1, 3);
// The columns are now reordered, but
// their original indexes have not
// changed.
// A C D B
// index: 0 2 3 1
// order: 0 1 2 3
The getOrderIndex method enables you to retrieve the order of a column at a particular index.
UILayoutManager
|
+--UIRowLayout
public UIRowLayout(int columns);
Creates a row layout manager with the specified number of columns.
Parameter | Description |
columns
| The number of columns to create.
|
Exceptions:
IllegalArgumentException
if a negative number of columns was specified.
public UIRowLayout(IUIComponent header, int columns);
Creates a row layout manager with the specified reference header and number of columns.
Parameter | Description |
header
| The reference object that all other containers using this layout manager will use to determine their offset.
|
columns
| The number of columns to create.
|
Exceptions:
IllegalArgumentException
if a negative number of columns is specified.
public UIRowLayout(IUIComponent header, int columns, int widths);
Creates a row layout manager with the specified reference header, number of columns, and initial width for those columns.
Parameter | Description |
header
| The reference object that all other containers using this layout manager will use to determine their offset.
|
columns
| The number of columns to create.
|
widths
| The initial width for each column.
|
Exceptions:
IllegalArgumentException
if a negative number of columns is specified.
public UIRowLayout(IUIComponent header, int columns, int widths[]);
Creates a row layout manager with the specified reference header, number of columns, and initial widths for those columns.
Parameter | Description |
header
| The reference object that all other containers using this layout manager will use to determine their offset.
|
columns
| The number of columns to create.
|
widths
| Array of the initial width for each column.
|
Exceptions:
IllegalArgumentException
if a negative number of columns is specified.
public IUIComponent getComponent(IUIContainer cont, int index);
Retrieves the component at the specified index.
Return Value:
Returns the specified component, if found; otherwise, returns null.
Parameter | Description |
cont
| The container of the component.
|
index
| The index of the component to retrieve.
|
Remarks:
For more information about a column's index, see the UIRowLayout overview.
Overrides:
getComponent(IUIContainer,int) in UILayoutManager.
Exceptions:
IllegalArgumentException
if an invalid index was specified.
public Dimension getMinimumSize(IUIContainer parent);
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 |
parent
| The container of the components.
|
Remarks:
This method is called by the container's getMinimumSize method. The height of the returned Dimension object is the largest of the minimum heights of each column, plus the container's top and bottom insets. The width is the sum of the widths of the columns plus the container's left and right insets. If the setWidth method has been called for a column, this new width is used to compute the container's width; otherwise, the column's minimum width is used.
Overrides:
getMinimumSize(IUIContainer) in UILayoutManager.
See Also: getPreferredSize
public int getOrderIndex(int index);
Retrieves the order of the column at the specified index.
Return Value:
Returns the zero-based order of the column.
Parameter | Description |
index
| The zero-based index of the column.
|
Remarks:
For more information about a column's index and order, see the UIRowLayout overview.
Exceptions:
IllegalArgumentException
if an invalid index was specified.
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 height of the returned Dimension object is the largest of the preferred heights of each column. The width is the sum of the widths of the columns. If the setWidth method has been called for a column, this new width is used to compute the container's width; otherwise, the column's preferred width is used.
Overrides:
getPreferredSize(IUIContainer) in UILayoutManager.
See Also: getMinimumSize
public int getWidth(int index);
Retrieves the current width of the column at the specified index.
Return Value:
Returns the width (in pixels) of the specified column.
Parameter | Description |
index
| The zero-based index of the column.
|
Remarks:
For more information about a column's index, see the UIRowLayout overview.
Exceptions:
IllegalArgumentException
if an invalid index was specified.
See Also: setWidth
public int[] getWidths();
Retrieves the current widths for all the columns.
Return Value:
Returns an array of the widths (in pixels) for each of the columns.
Remarks:
For more information about a column's index, see the UIRowLayout overview.
Exceptions:
IllegalArgumentException
if an invalid index was specified.
See Also: setWidths
public boolean isOverlapping();
This method simply returns false, indicated that the UIRowLayout lays out its components such that they never overlap.
Return Value:
Returns false.
Overrides:
isOverlapping() in UILayoutManager.
public boolean isWidthRelative();
This method simply returns false indicating that the UIRowLayout does not layout its components based on the width of the container.
Return Value:
Returns false.
Overrides:
isWidthRelative() in UILayoutManager.
See Also: isHeightRelative
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:
This method is called by the container's layout method. By default, the bounding rectangle's width is divided equally among the number of components, or columns, so that each column has the same width, with no gap between columns. The height of each column is the height of the bounding rectangle. If the setWidth method is later called to change the width of a column, layout uses the new column width.
Overrides:
layout(IUIContainer,Rectangle) in UILayoutManager.
public void moveColumn(int from, int to);
Moves a column from one location to another.
Return Value:
No return value.
Parameter | Description |
from
| The zero-based index that identifies the column to move.
|
to
| The zero-based index that identifies where the column is moving to.
|
Remarks:
For more information about moving columns, see the UIRowLayout overview.
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 setWidth(int index, int width);
Sets the width of the column at the specified index.
Return Value:
No return value.
Parameter | Description |
index
| The zero-based index of the column.
|
width
| The new width (in pixels) for the column.
|
Remarks:
For more information about a column's index, see the UIRowLayout overview.
Exceptions:
IllegalArgumentException
if an invalid index was specified.
See Also: getWidth
public void setWidths(int width);
Sets the widths of all columns to the specified width.
Return Value:
No return value.
Parameter | Description |
widths
| The new width (in pixels) for each column.
|
Remarks:
For more information about a column's index, see the UIRowLayout overview.
Exceptions:
IllegalArgumentException
if an invalid index was specified.
See Also: getWidths
public void setWidths(int widths[]);
Sets all the column widths to the specified widths.
Return Value:
No return value.
Parameter | Description |
widths
| The array of new widths (in pixels) for each column.
|
Remarks:
For more information about a column's index, see the UIRowLayout overview.
Exceptions:
IllegalArgumentException
if an invalid index was specified.
See Also: getWidths