Class UISingleContainer
public class UISingleContainer extends UIStateContainer
{
// Constructors
public UISingleContainer();
public UISingleContainer(int edge);
// Methods
public IUIComponent add(IUIComponent comp, Object constraints,
int index);
public IUIComponent getChild(int index);
public Rectangle getChildBounds(int index);
public int getChildCount();
public Point getChildLocation(int index);
public Dimension getChildSize(int index);
public IUIComponent getComponent(int index);
public int getComponentCount();
public IUIComponent getHeader();
public void layout();
public boolean mouseExit(Event e, int x, int y);
public void relayout();
public void remove(int index);
public void setFocused(boolean on);
public void setHeader(IUIComponent header);
public void setID(int id);
public void setName(String name);
}
This class implements a container for a single header component. Header components are used to represent the container itself; for example, the text displayed on a button is used as its header component. Unlike UIPanel, a UISingleContainer object cannot contain child components. UISingleContainer provides the getHeader and setHeader methods to retrieve and set the current header component.
The following diagram shows the classes that extend UISingleContainer.
UISingleContainer
|
+--UIButton
|
+--UIMenuLauncher
|
+--UIStatus
|
+--UITab
|
+--UIThumb
UIComponent
|
+--UIContainer
|
+--UIStateContainer
|
+--UISingleContainer
public UISingleContainer();
Creates a UISingleContainer object with no edge.
public UISingleContainer(int edge);
Creates a UISingleContainer object with the specified edge.
Parameter | Description |
edge
| The style of the container's edge. You can pass one of the following values:
|
Exceptions:
IllegalArgumentException
if an undefined edge style was specified.
public IUIComponent add(IUIComponent comp, Object constraints, int index);
Adds the specified component to the container, according to the specified constraints and index.
Return Value:
Returns the component that was added (if successful); otherwise, returns null.
Parameter | Description |
comp
| The component to be added.
|
constraints
| The layout constraints, which depend on the current layout manager. For more information, see the layout manager's addLayoutComponent method.
|
index
| The zero-based index at which to insert the component. Because the component can only be added as a header, possible index values include 0 or -1. (For more information about header components, see the UISingleContainer overview.)
|
Remarks:
Other versions of add are inherited from UIContainer.
Overrides:
add(IUIComponent,Object,int) in UIStateContainer.
Exceptions:
ArrayIndexOutOfBoundsException
if an invalid index was specified.
See Also: remove
public IUIComponent getChild(int index);
Retrieves the child component at the specified index.
Return Value:
Returns null, because the container can only contain a header component and no child components.
Parameter | Description |
index
| The zero-based index of the child component to be retrieved.
|
See Also: getComponent, getChildCount
public Rectangle getChildBounds(int index);
Retrieves the bounding rectangle of the component at the specified index.
Return Value:
Returns a Rectangle object that identifies the component's bounding area (if the component is the container's header); otherwise, returns null.
Parameter | Description |
index
| The zero-based index of the component. Because the container can only contain a header component, this method returns null if an index other than 0 is passed.
|
public int getChildCount();
Retrieves the number of child components in the container, excluding the header component.
Return Value:
Returns 0, because the container can only contain a header component.
See Also: getComponentCount, getChild
public Point getChildLocation(int index);
Retrieves the location of the component at the specified index.
Return Value:
Returns a Point object containing the top-left corner of the component (if the component is the container's header); otherwise, returns null.
Parameter | Description |
index
| The zero-based index of the component. Because the container can only contain a header component, this method returns null if an index other than 0 is passed.
|
public Dimension getChildSize(int index);
Retrieves the size of the component at the specified index.
Return Value:
Returns a Dimension object containing the component's dimensions (if the component is the container's header); otherwise, returns null.
Parameter | Description |
index
| The zero-based index of the component. Because the container can only contain a header component, this method returns null if an index other than 0 is passed.
|
public IUIComponent getComponent(int index);
Retrieves the component at the specified index.
Return Value:
Returns the component at the specified index, if found; otherwise, returns null.
Parameter | Description |
index
| The zero-based index of the component to be retrieved. Because the container can only contain a header component, pass 0 to retrieve the header. This method returns null if any other index is passed.
|
See Also: getChild, getComponentCount
public int getComponentCount();
Retrieves the number of components in the container.
Return Value:
Returns 1 if a header component is set; otherwise, returns 0.
See Also: getChildCount, getComponent
public IUIComponent getHeader();
Retrieves the container's header component.
Return Value:
Returns the current header component (if the container has a header); otherwise, returns null. For more information about headers, see the UISingleContainer overview.
See Also: setHeader
public void layout();
Lays out the container.
Return Value:
No return value.
Remarks:
This method is invoked when the container is validated.
See Also: relayout
public boolean mouseExit(Event e, int x, int y);
Responds to a mouse exit event.
Return Value:
Returns true if the event was handled; otherwise, returns false.
Parameter | Description |
e
| The event posted to the container.
|
x
| The x coordinate of the event.
|
y
| The y coordinate of the event.
|
Remarks:
This method prevents excess flickering when the mouse is moved in and out of the container. A mouse exit event is generated when the mouse exits the container's insets and enters the header component, and vice versa. In these cases, the mouseExit method simply returns false.
public void relayout();
Schedules the container to be laid out as soon as possible.
Return Value:
No return value.
See Also: layout
public void remove(int index);
Removes the component at the specified index.
Return Value:
No return value.
Parameter | Description |
index
| The zero-based index of the component to be removed. Because the container can only contain a header component, pass 0 to remove the header.
|
Overrides:
remove(int) in UIStateContainer.
See Also: add
public void setFocused(boolean on);
Sets or clears the focus state of the button.
Return Value:
No return value.
Parameter | Description |
on
| If true, the focus state is set; otherwise, it is cleared.
|
Remarks:
For more information about states, see the UIStateContainer overview.
Overrides:
setFocused(boolean) in UIStateContainer.
public void setHeader(IUIComponent header);
Sets the header component for the container.
Return Value:
No return value.
Parameter | Description |
header
| The component to be used as the container's header component. For more information about headers, see the UISingleContainer overview.
|
See Also: getHeader
public void setID(int id);
Sets the container's identifier.
Return Value:
No return value.
Parameter | Description |
id
| The value to be associated with the container.
|
See Also: setName
public void setName(String name);
Sets the container's name.
Return Value:
No return value.
Parameter | Description |
name
| The name to be associated with the container.
|
See Also: setID