Class UIStateContainer
abstract public class UIStateContainer extends UIContainer
{
// Constructors
public UIStateContainer();
public UIStateContainer(int edge);
// Methods
public IUIComponent add(IUIComponent comp, Object constraints,
int index);
public synchronized void addContainerListener(
IUIContainerListener l);
public synchronized void addFocusListener(IUIFocusListener l);
public synchronized void addKeyListener(IUIKeyListener l);
public synchronized void addMouseListener(IUIMouseListener l);
public synchronized void addMouseMotionListener(
IUIMouseMotionListener l);
public void addNotify();
public void adjustLayoutSize(Dimension oldSize,
Dimension newSize);
protected final void disableEvents(long eventsToDisable);
protected final void enableEvents(long eventsToEnable);
public Color getBackground();
public Dimension getCachedPreferredSize();
public Cursor getCursor();
public int getEdge();
public int getFlags();
public Font getFont();
public Color getForeground();
public int getIndex();
public IUIContainer getParent();
public boolean isChecked();
public boolean isEnabled();
public boolean isFocused();
public boolean isHot();
public boolean isIndeterminate();
public boolean isInvalidating();
public boolean isNotified();
public boolean isPressed();
public boolean isRedrawing();
public boolean isSelected();
public boolean isValid();
public boolean isVisible();
public boolean postEvent(Event evt);
protected void processContainerEvent(UIContainerEvent e);
protected void processEvent(UIEvent e);
protected void processFocusEvent(UIFocusEvent e);
protected void processKeyEvent(UIKeyEvent e);
protected void processMouseEvent(UIMouseEvent e);
protected void processMouseMotionEvent(UIMouseEvent e);
public void recalcPreferredSize();
public void remove(int index);
public synchronized void removeContainerListener(
IUIContainerListener l);
public synchronized void removeFocusListener(IUIFocusListener l);
public synchronized void removeKeyListener(IUIKeyListener l);
public synchronized void removeMouseListener(IUIMouseListener l);
public synchronized void removeMouseMotionListener(
IUIMouseMotionListener l);
public void removeNotify();
public void setBackground(Color color);
public void setChecked(boolean on);
public void setCursor(Cursor cursor);
public void setEdge(int edge);
public void setEnabled(boolean on);
public void setFlags(int flags);
public void setFocused(boolean on);
public void setFont(Font font);
public void setForeground(Color color);
public void setHot(boolean on);
public void setIndeterminate(boolean on);
public void setIndex(int index);
public void setInvalidating(boolean on);
public void setParent(IUIContainer parent);
public void setPressed(boolean on);
public void setRedrawing(boolean on);
public void setSelected(boolean on);
public void setValid(boolean valid);
public void setVisible(boolean show);
}
This class implements a container having different states. UIStateContainer extends UIContainer to manage the states shown in the following table.
State
|
Description
|
checked
|
Typically applies to buttons. For example, when a UICheckButton object is checked, its check box image displays a check. When the button is unchecked, the check box image is cleared.
|
enabled
|
The object can respond to user input.
|
focused
|
All subsequent keyboard input is sent to the object.
|
hot-tracked
|
Identifies the object currently under the mouse. When the mouse enters the object, any text displayed by the object turns blue (by default). When the mouse exits, the text's original color is restored.
|
indeterminate
|
Typically applies to buttons. For example, when a UICheckButton object's indeterminate state is set, the check box image displays a gray check.
|
notified
|
An object is notified when the graphics context first becomes available.
|
pressed
|
The mouse button is currently being pressed over the object. When the mouse button is released, the object is unpressed.
|
redrawing
|
Controls the painting of the object. When a paint request is made, the object will be redrawn only if its redrawing state set.
|
selected
|
Indicates the user's selection. For example, when the user clicks an item in a single-selection UIList object, that item becomes selected, and any previously selected item is deselected.
|
valid
|
The layout of the object is current. For example, when the size of the object changes, the object is marked as invalid. When the size is recomputed and the layout is updated, the object is valid again.
|
visible
|
The object is showing.
|
Two classes that extend UIStateContainer include UIPanel and UISingleContainer. A UIPanel object can contain multiple child components and a header component. A UISingleContainer object contains only a 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.
Note The hot-track color is the same color as the button text color. As a result, hot-tracking does not appear to be functional.
UIComponent
|
+--UIContainer
|
+--UIStateContainer
public UIStateContainer();
Creates a state container with no edge.
public UIStateContainer(int edge);
Creates a state container with the specified edge.
Parameter | Description |
edge
| The style of the container's edge. You can pass one of the following values for an edge style:
|
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 about layout constraints, see the layout manager's addLayoutComponent method.
|
index
| The zero-based index at which to insert the component. If the container has a header component, the header is at index 0, and the first child component begins at index 1; otherwise, the first child begins at index 0. To add the component at the end of the container, pass -1. (For more information about header components, see the UIStateContainer overview.)
|
Overrides:
add(IUIComponent,Object,int) in UIContainer.
See Also: remove
public synchronized void addContainerListener(IUIContainerListener l);
Adds the specified container listener. The listener receives all container events generated for the control.
Return Value:
No return value.
Parameter | Description |
l
| The container listener to be added.
|
See Also: removeContainerListener
public synchronized void addFocusListener(IUIFocusListener l);
Adds the specified focus listener. The listener receives all focus events generated for the control.
Return Value:
No return value.
Parameter | Description |
l
| The focus listener to be added.
|
See Also: removeFocusListener
public synchronized void addKeyListener(IUIKeyListener l);
Adds the specified key listener. The listener receives all key events generated for the control.
Return Value:
No return value.
Parameter | Description |
l
| The key listener to be added.
|
See Also: removeKeyListener
public synchronized void addMouseListener(IUIMouseListener l);
Adds the specified mouse listener. The listener receives all mouse events generated for the control.
Return Value:
No return value.
Parameter | Description |
l
| The mouse listener to be added.
|
See Also: removeMouseListener
public synchronized void addMouseMotionListener(IUIMouseMotionListener l);
Adds the specified mouse motion listener. The listener receives all mouse motion events generated for the control.
Return Value:
No return value.
Parameter | Description |
l
| The mouse motion listener to be added.
|
See Also: removeMouseMotionListener
public void addNotify();
Called to perform initialization when the graphics context is first available.
Return Value:
No return value.
Remarks:
This method invalidates the container and sets its notified state. The addNotify method is then invoked for each component in the container.
Overrides:
addNotify() in UIContainer.
See Also: removeNotify
public void adjustLayoutSize(Dimension oldSize, Dimension newSize);
Adjusts the layout size of the container.
Return Value:
No return value.
Parameter | Description |
oldSize
| The previous layout size of the container (in pixels).
|
newSize
| The new layout size of the container (in pixels).
|
Remarks:
This method is automatically invoked when the container's size has changed.
protected final void disableEvents(long eventsToDisable);
Disables the events defined by the specified event mask parameter from being delivered to this component.
Return Value:
No return value.
Parameter | Description |
eventsToDisable
| the event mask defining the event types.
|
protected final void enableEvents(long eventsToEnable);
Enables the events defined by the specified event mask parameter to be delivered to this component.
Return Value:
No return value.
Parameter | Description |
eventsToEnable
| the event mask defining the event types.
|
Remarks:
Event types are automatically enabled when a listener for that type is added to the component; therefore, this method only needs to be invoked by subclasses of a component that require the specified event types delivered to processEvent, regardless of whether a listener is registered.
public Color getBackground();
Retrieves the background color of the container.
Return Value:
Returns a Color object containing the container's background color.
Remarks:
If the container itself does not have a background color, this method returns the background color of the container's parent.
See Also: setBackground, getParent
public Dimension getCachedPreferredSize();
Retrieves the container's preferred size (in pixels).
Return Value:
Returns a Dimension object containing the preferred size.
public Cursor getCursor();
Retrieves the container's cursor.
Return Value:
Returns a Cursor object containing the container's cursor.
Remarks:
If the container itself does not have a cursor, this method returns the cursor of the container's parent.
See Also: setFont, getParent
public int getEdge();
Retrieves the style of the container's edge.
Return Value:
Returns an integer containing the current style settings for the container's edge. For a list of possible values, see setEdge.
Overrides:
getEdge() in UIContainer.
public int getFlags();
Retrieves the user-defined bits currently set for the container.
Return Value:
Returns an integer containing the current user-defined settings.
See Also: setFlags
public Font getFont();
Retrieves the font of the container.
Return Value:
Returns a Font object containing the container's font.
Remarks:
If the container itself does not have a font, this method returns the font of the container's parent.
See Also: setFont, getParent
public Color getForeground();
Retrieves the foreground color of the container.
Return Value:
Returns a Color object containing the container's foreground color.
Remarks:
If the container itself does not have a foreground color, this method returns the foreground color of the container's parent.
See Also: setForeground, getParent
public int getIndex();
Retrieves the index of the container within its parent.
Return Value:
Returns the container's index.
See Also: setIndex
public IUIContainer getParent();
Retrieves the container's parent.
Return Value:
Returns the parent container.
See Also: setParent
public boolean isChecked();
Determines whether the container's checked state is set.
Return Value:
Returns true if the container is checked; otherwise, returns false.
See Also: setChecked
public boolean isEnabled();
Determines whether the container's enabled state is set.
Return Value:
Returns true if the container is enabled; returns false if disabled.
See Also: setEnabled
public boolean isFocused();
Determines whether the container's focus state is set.
Return Value:
Returns true if the container has focus; otherwise, returns false.
See Also: setFocused
public boolean isHot();
Determines whether the container's hot-tracked state is set.
Return Value:
Returns true if the container is hot-tracked; otherwise, returns false.
See Also: setHot
public boolean isIndeterminate();
Determines whether the container's indeterminate state is set.
Return Value:
Returns true if the container is indeterminate; otherwise, returns false.
See Also: setIndeterminate
public boolean isInvalidating();
Retrieves the current invalidating state of this object.
Return Value:
Returns true if this object has invalidating enabled; otherwise, returns false (which means it will ignore requests to invalidate).
public boolean isNotified();
Determines whether the container's notified state is set.
Return Value:
Returns true if the container is notified; otherwise, returns false.
See Also: addNotify, removeNotify
public boolean isPressed();
Determines whether the container's pressed state is set.
Return Value:
Returns true if the container is pressed; otherwise, returns false.
See Also: setPressed
public boolean isRedrawing();
Determines whether the container will be redrawn when a paint request is made.
Return Value:
Returns true if the redrawing state is set; otherwise, returns false.
See Also: setRedrawing
public boolean isSelected();
Determines whether the container's selected state is set.
Return Value:
Returns true if the container is selected; otherwise, returns false.
See Also: setSelected
public boolean isValid();
Determines whether the container is valid.
Return Value:
Returns true if the container is valid; returns false if invalid.
See Also: setValid
public boolean isVisible();
Determines whether the container's visible state is set.
Return Value:
Returns true if the container is visible; otherwise, returns false.
See Also: setVisible
public boolean postEvent(Event evt);
Posts the specified event to the container.
Return Value:
Returns true if the event was handled; otherwise, returns false.
Parameter | Description |
evt
| The event.
|
protected void processContainerEvent(UIContainerEvent e);
Processes container events.
Return Value:
No return value.
Parameter | Description |
e
| The container event.
|
Remarks:
This method is called by processEvent and dispatches the event to a registered key listener. When overriding this method, call the super method processContainerEvent to ensure the default event processing continues normally.
See Also: addContainerListener
protected void processEvent(UIEvent e);
Processes the specified event.
Return Value:
No return value.
Parameter | Description |
e
| The event.
|
Remarks:
This method is automatically invoked if a listener has has been registered through a call to addXXXListener. Depending on the type of event, processEvent calls one of the following methods.
When overriding processEvent, call the super method processEvent to ensure the default event processing continues normally.
protected void processFocusEvent(UIFocusEvent e);
Processes focus events.
Return Value:
No return value.
Parameter | Description |
e
| The focus event.
|
Remarks:
This method is called by processEvent and dispatches the event to a registered focus listener. When overriding this method, call the super method processFocusEvent to ensure the default event processing continues normally.
See Also: addFocusListener
protected void processKeyEvent(UIKeyEvent e);
Processes key events.
Return Value:
No return value.
Parameter | Description |
e
| The key event.
|
Remarks:
This method is called by processEvent and dispatches the event to a registered key listener. When overriding this method, call the super method processKeyEvent to ensure the default event processing continues normally.
See Also: addKeyListener
protected void processMouseEvent(UIMouseEvent e);
Processes mouse events.
Return Value:
No return value.
Parameter | Description |
e
| The mouse event.
|
Remarks:
This method is called by processEvent and dispatches the event to a registered mouse listener. When overriding this method, call the super method processMouseEvent to ensure the default event processing continues normally.
See Also: addMouseListener
protected void processMouseMotionEvent(UIMouseEvent e);
Processes mouse motion events.
Return Value:
No return value.
Parameter | Description |
e
| The mouse motion event.
|
Remarks:
This method is called by processEvent and dispatches the event to a registered mouse motion listener. When overriding this method, call the super method processMouseMotionEvent to ensure the default event processing continues normally.
See Also: addMouseMotionListener
public void recalcPreferredSize();
Recalculates the container's preferred size (in pixels).
Return Value:
No return value.
public void remove(int index);
Removes the component at the specified index from the container.
Return Value:
No return value.
Parameter | Description |
index
| The zero-based index of the component to be removed. If the container has a header component, the header is at index 0 and the first child componentbegins at index 1; otherwise, the first child begins at index 0. (For more information about header components, see the UIStateContainer overview.)
|
Overrides:
remove(int) in UIContainer.
See Also: add
public synchronized void removeContainerListener(IUIContainerListener l);
Removes the specified container listener. The listener no longer receives the control's container events.
Return Value:
No return value.
Parameter | Description |
l
| The container listener to be removed.
|
See Also: addContainerListener
public synchronized void removeFocusListener(IUIFocusListener l);
Removes the specified focus listener. The listener no longer receives the control's focus events.
Return Value:
No return value.
Parameter | Description |
l
| The focus listener to be removed.
|
See Also: addFocusListener
public synchronized void removeKeyListener(IUIKeyListener l);
Removes the specified key listener. The listener no longer receives the control's key events.
Return Value:
No return value.
Parameter | Description |
l
| The key listener to be removed.
|
See Also: addKeyListener
public synchronized void removeMouseListener(IUIMouseListener l);
Removes the specified mouse listener. The listener no longer receives the control's mouse events.
Return Value:
No return value.
Parameter | Description |
l
| The mouse listener to be removed.
|
See Also: addMouseListener
public synchronized void removeMouseMotionListener(
IUIMouseMotionListener l);
Removes the specified mouse motion listener. The listener no longer receives the control's mouse motion events.
Return Value:
No return value.
Parameter | Description |
l
| The mouse motion listener to be removed.
|
See Also: addMouseMotionListener
public void removeNotify();
Called when the graphics context first becomes unavailable.
Return Value:
No return value.
Remarks:
This method clears the notified state and invokes removeNotify for each component in the container.
Overrides:
removeNotify() in UIContainer.
See Also: addNotify
public void setBackground(Color color);
Sets the container's background color.
Return Value:
No return value.
Parameter | Description |
color
| The background color for the container.
|
See Also: getBackground
public void setChecked(boolean on);
Sets or clears the checked state of the container.
Return Value:
No return value.
Parameter | Description |
on
| If true, the checked state is set; otherwise, it is cleared.
|
See Also: isChecked
public void setCursor(Cursor cursor);
Sets the container's cursor.
Return Value:
No return value.
Parameter | Description |
cursor
| The cursor for the container.
|
See Also: getCursor
public void setEdge(int edge);
Sets the style of the container's edge.
Return Value:
No return value.
Parameter | Description |
edge
| The style of the container's edge. You can pass one of the following values:
|
Overrides:
setEdge(int) in UIContainer.
Exceptions:
IllegalArgumentException
if an undefined edge style was specified.
See Also: getEdge
public void setEnabled(boolean on);
Sets or clears the enabled state of the container.
Return Value:
No return value.
Parameter | Description |
on
| If true, the enabled state is set; otherwise, it is cleared.
|
See Also: isEnabled
public void setFlags(int flags);
Sets the user-defined bits for the container.
Return Value:
No return value.
Parameter | Description |
flags
| The user-defined settings for the container. You can set any bit in the mask 0xFFF00000.
|
Exceptions:
IllegalArgumentException
if an undefined bit was specified.
See Also: getFlags
public void setFocused(boolean on);
Sets or clears the focus state of the container.
Return Value:
No return value.
Parameter | Description |
on
| If true, the focus state is set; otherwise, it is cleared.
|
Remarks:
This method is automatically invoked when the container receives or loses focus.
See Also: isFocused
public void setFont(Font font);
Sets the container's font.
Return Value:
No return value.
Parameter | Description |
font
| The font for the container.
|
See Also: getFont
public void setForeground(Color color);
Sets the container's foreground color.
Return Value:
No return value.
Parameter | Description |
color
| The foreground color for the container.
|
See Also: getForeground
public void setHot(boolean on);
Sets or clears the hot-tracked state of the container.
Return Value:
No return value.
Parameter | Description |
on
| If true, the hot-tracked state is set; otherwise, it is cleared.
|
Remarks:
This method is automatically invoked when the mouse enters and exits the container.
See Also: isHot
public void setIndeterminate(boolean on);
Sets or clears the indeterminate state of the container.
Return Value:
No return value.
Parameter | Description |
on
| If true, the indeterminate state is set and the checked state is cleared. If false, the indeterminate state is cleared.
|
See Also: isIndeterminate, setChecked
public void setIndex(int index);
Sets the index of the container within its parent.
Parameter | Description |
index
| The index for the container.
|
See Also: getIndex
public void setInvalidating(boolean on);
Sets the invalidating state of this object.
Return Value:
No return value.
Parameter | Description |
on
| The invalidating state setting.
|
public void setParent(IUIContainer parent);
Sets the container's parent. If the container already has a parent, it is removed from that parent's hierarchy.
Return Value:
No return value.
Parameter | Description |
parent
| The new parent container.
|
See Also: getParent
public void setPressed(boolean on);
Sets or clears the pressed state of the container.
Return Value:
No return value.
Parameter | Description |
on
| If true, the pressed state is set; otherwise, it is cleared.
|
Remarks:
This method is automatically invoked when the mouse button is pressed, released, or dragged over the container.
See Also: isPressed
public void setRedrawing(boolean on);
Sets or clears the redrawing state of the container. If the redrawing state is set, the container will be redrawn when a paint request is made. If the redrawing state is cleared, the container will not be redrawn.
Return Value:
No return value.
Parameter | Description |
on
| If true, the redrawing state is set; otherwise, it is cleared.
|
See Also: isRedrawing
public void setSelected(boolean on);
Sets or clears the selected state of the container.
Return Value:
No return value.
Parameter | Description |
on
| If true, the selected state is set; otherwise, it is cleared.
|
See Also: isSelected
public void setValid(boolean valid);
Sets or clears the valid state of the container.
Return Value:
No return value.
Parameter | Description |
valid
| If true, the container's valid state is set and the container is validated; otherwise, the container is invalidated.
|
public void setVisible(boolean show);
Sets or clears the visible state of the container.
Return Value:
No return value.
Parameter | Description |
show
| If true, the container is shown; otherwise, the container is hidden.
|
See Also: isVisible