Packages
 In this topic

*Constructors

*Methods

 

Packages   PreviousThis PackageNext
Package com.ms.ui   Previous This
Package
Next

 


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

Constructors

UIStateContainer

public UIStateContainer();

Creates a state container with no edge.

UIStateContainer

public UIStateContainer(int edge);

Creates a state container with the specified edge.

ParameterDescription
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.

Methods

add

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.

ParameterDescription
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

addContainerListener

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.

ParameterDescription
l The container listener to be added.

See Also: removeContainerListener

addFocusListener

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.

ParameterDescription
l The focus listener to be added.

See Also: removeFocusListener

addKeyListener

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.

ParameterDescription
l The key listener to be added.

See Also: removeKeyListener

addMouseListener

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.

ParameterDescription
l The mouse listener to be added.

See Also: removeMouseListener

addMouseMotionListener

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.

ParameterDescription
l The mouse motion listener to be added.

See Also: removeMouseMotionListener

addNotify

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

adjustLayoutSize

public void adjustLayoutSize(Dimension oldSize, Dimension newSize);

Adjusts the layout size of the container.

Return Value:

No return value.

ParameterDescription
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.

disableEvents

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.

ParameterDescription
eventsToDisable the event mask defining the event types.

enableEvents

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.

ParameterDescription
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.

getBackground

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

getCachedPreferredSize

public Dimension getCachedPreferredSize();

Retrieves the container's preferred size (in pixels).

Return Value:

Returns a Dimension object containing the preferred size.

getCursor

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

getEdge

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.

getFlags

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

getFont

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

getForeground

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

getIndex

public int getIndex();

Retrieves the index of the container within its parent.

Return Value:

Returns the container's index.

See Also: setIndex

getParent

public IUIContainer getParent();

Retrieves the container's parent.

Return Value:

Returns the parent container.

See Also: setParent

isChecked

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

isEnabled

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

isFocused

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

isHot

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

isIndeterminate

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

isInvalidating

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).

isNotified

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

isPressed

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

isRedrawing

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

isSelected

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

isValid

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

isVisible

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

postEvent

public boolean postEvent(Event evt);

Posts the specified event to the container.

Return Value:

Returns true if the event was handled; otherwise, returns false.

ParameterDescription
evt The event.

processContainerEvent

protected void processContainerEvent(UIContainerEvent e);

Processes container events.

Return Value:

No return value.

ParameterDescription
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

processEvent

protected void processEvent(UIEvent e);

Processes the specified event.

Return Value:

No return value.

ParameterDescription
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.

Event type Method called
container event processContainerEvent
focus event processFocusEvent
key event processKeyEvent
mouse event processMouseEvent
mouse motion event processMouseMotionEvent

When overriding processEvent, call the super method processEvent to ensure the default event processing continues normally.

processFocusEvent

protected void processFocusEvent(UIFocusEvent e);

Processes focus events.

Return Value:

No return value.

ParameterDescription
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

processKeyEvent

protected void processKeyEvent(UIKeyEvent e);

Processes key events.

Return Value:

No return value.

ParameterDescription
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

processMouseEvent

protected void processMouseEvent(UIMouseEvent e);

Processes mouse events.

Return Value:

No return value.

ParameterDescription
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

processMouseMotionEvent

protected void processMouseMotionEvent(UIMouseEvent e);

Processes mouse motion events.

Return Value:

No return value.

ParameterDescription
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

recalcPreferredSize

public void recalcPreferredSize();

Recalculates the container's preferred size (in pixels).

Return Value:

No return value.

remove

public void remove(int index);

Removes the component at the specified index from the container.

Return Value:

No return value.

ParameterDescription
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

removeContainerListener

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.

ParameterDescription
l The container listener to be removed.

See Also: addContainerListener

removeFocusListener

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.

ParameterDescription
l The focus listener to be removed.

See Also: addFocusListener

removeKeyListener

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.

ParameterDescription
l The key listener to be removed.

See Also: addKeyListener

removeMouseListener

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.

ParameterDescription
l The mouse listener to be removed.

See Also: addMouseListener

removeMouseMotionListener

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.

ParameterDescription
l The mouse motion listener to be removed.

See Also: addMouseMotionListener

removeNotify

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

setBackground

public void setBackground(Color color);

Sets the container's background color.

Return Value:

No return value.

ParameterDescription
color The background color for the container.

See Also: getBackground

setChecked

public void setChecked(boolean on);

Sets or clears the checked state of the container.

Return Value:

No return value.

ParameterDescription
on If true, the checked state is set; otherwise, it is cleared.

See Also: isChecked

setCursor

public void setCursor(Cursor cursor);

Sets the container's cursor.

Return Value:

No return value.

ParameterDescription
cursor The cursor for the container.

See Also: getCursor

setEdge

public void setEdge(int edge);

Sets the style of the container's edge.

Return Value:

No return value.

ParameterDescription
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

setEnabled

public void setEnabled(boolean on);

Sets or clears the enabled state of the container.

Return Value:

No return value.

ParameterDescription
on If true, the enabled state is set; otherwise, it is cleared.

See Also: isEnabled

setFlags

public void setFlags(int flags);

Sets the user-defined bits for the container.

Return Value:

No return value.

ParameterDescription
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

setFocused

public void setFocused(boolean on);

Sets or clears the focus state of the container.

Return Value:

No return value.

ParameterDescription
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

setFont

public void setFont(Font font);

Sets the container's font.

Return Value:

No return value.

ParameterDescription
font The font for the container.

See Also: getFont

setForeground

public void setForeground(Color color);

Sets the container's foreground color.

Return Value:

No return value.

ParameterDescription
color The foreground color for the container.

See Also: getForeground

setHot

public void setHot(boolean on);

Sets or clears the hot-tracked state of the container.

Return Value:

No return value.

ParameterDescription
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

setIndeterminate

public void setIndeterminate(boolean on);

Sets or clears the indeterminate state of the container.

Return Value:

No return value.

ParameterDescription
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

setIndex

public void setIndex(int index);

Sets the index of the container within its parent.

ParameterDescription
index The index for the container.

See Also: getIndex

setInvalidating

public void setInvalidating(boolean on);

Sets the invalidating state of this object.

Return Value:

No return value.

ParameterDescription
on The invalidating state setting.

setParent

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.

ParameterDescription
parent The new parent container.

See Also: getParent

setPressed

public void setPressed(boolean on);

Sets or clears the pressed state of the container.

Return Value:

No return value.

ParameterDescription
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

setRedrawing

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.

ParameterDescription
on If true, the redrawing state is set; otherwise, it is cleared.

See Also: isRedrawing

setSelected

public void setSelected(boolean on);

Sets or clears the selected state of the container.

Return Value:

No return value.

ParameterDescription
on If true, the selected state is set; otherwise, it is cleared.

See Also: isSelected

setValid

public void setValid(boolean valid);

Sets or clears the valid state of the container.

Return Value:

No return value.

ParameterDescription
valid If true, the container's valid state is set and the container is validated; otherwise, the container is invalidated.

setVisible

public void setVisible(boolean show);

Sets or clears the visible state of the container.

Return Value:

No return value.

ParameterDescription
show If true, the container is shown; otherwise, the container is hidden.

See Also: isVisible

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.