Packages
 In this topic

*Methods

 

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

 


Class UIStateComponent

abstract public class UIStateComponent extends UIComponent
{
  // Methods
  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 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 isValid();
  public boolean isVisible();
  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 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 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 component having different states. UIStateComponent extends UIComponent to manage the states shown in the following table.

State Description
checked Typically applies to buttons. For example, when a check box button 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 check box button'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 a UIText item in a single-selection list box, 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.

UIStateComponent defines methods to determine and set the component's current states.

UIStateComponent also allows a Listener to "consume" an input (key or mouse) event before passing it to the underlying UIComponent.

UICanvas extends UIStateComponent.

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
  |
  +--UIStateComponent

Methods

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.

Overrides:

addFocusListener(IUIFocusListener) in UIComponent.

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.

Overrides:

addKeyListener(IUIKeyListener) in UIComponent.

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.

Overrides:

addMouseListener(IUIMouseListener) in UIComponent.

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.

Overrides:

addMouseMotionListener(IUIMouseMotionListener) in UIComponent.

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 component and sets its notified state. The addNotify method of the superclass is then invoked.

Overrides:

addNotify() in UIComponent.

See Also: removeNotify

adjustLayoutSize

public void adjustLayoutSize(Dimension oldSize, Dimension newSize);

Invalidates the component and adjusts its layout size.

Return Value:

No return value.

ParameterDescription
oldSize The previous layout size of the component (in pixels).
newSize The new layout size of the component (in pixels).

Remarks:

This method is automatically invoked when the component's size has changed.

Overrides:

adjustLayoutSize(Dimension,Dimension) in UIComponent.

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. As a result, 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 component.

Return Value:

Returns a Color object containing the component's background color.

Remarks:

If the component itself does not have a background color, this method returns the background color of the component's parent.

Overrides:

getBackground() in UIComponent.

See Also: setBackground, getParent

getCachedPreferredSize

public Dimension getCachedPreferredSize();

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

Return Value:

Returns a Dimension object containing the preferred size.

Overrides:

getCachedPreferredSize() in UIComponent.

getCursor

public Cursor getCursor();

Retrieves the component's cursor.

Return Value:

Returns a Cursor object containing the component's cursor.

Remarks:

If the component itself does not have a cursor, this method returns the cursor of the component's parent.

Overrides:

getCursor() in UIComponent.

See Also: setFont, getParent

getFlags

public int getFlags();

Retrieves the user-defined bits currently set for the component.

Return Value:

Returns an integer containing the current user-defined settings.

Overrides:

getFlags() in UIComponent.

See Also: setFlags

getFont

public Font getFont();

Retrieves the font of the component.

Return Value:

Returns a Font object containing the component's font.

Remarks:

If the component itself does not have a font, this method returns the font of the component's parent.

Overrides:

getFont() in UIComponent.

See Also: setFont, getParent

getForeground

public Color getForeground();

Retrieves the foreground color of the component.

Return Value:

Returns a Color object containing the component's foreground color.

Remarks:

If the component itself does not have a foreground color, this method returns the foreground color of the component's parent.

Overrides:

getForeground() in UIComponent.

See Also: setForeground, getParent

getIndex

public int getIndex();

Retrieves the index of the control within its parent container.

Return Value:

Returns the control's index.

Overrides:

getIndex() in UIComponent.

See Also: setIndex

getParent

public IUIContainer getParent();

Retrieves the component's parent.

Return Value:

Returns the parent container of the component.

Overrides:

getParent() in UIComponent.

See Also: setParent

isChecked

public boolean isChecked();

Determines whether the component's checked state is set.

Return Value:

Returns true if the component is checked; otherwise, returns false.

Overrides:

isChecked() in UIComponent.

See Also: setChecked

isEnabled

public boolean isEnabled();

Determines whether the component's enabled state is set.

Return Value:

Returns true if the component is enabled; returns false if disabled.

Overrides:

isEnabled() in UIComponent.

See Also: setEnabled

isFocused

public boolean isFocused();

Determines whether the component's focus state is set.

Return Value:

Returns true if the component has focus; otherwise, returns false.

Overrides:

isFocused() in UIComponent.

See Also: setFocused

isHot

public boolean isHot();

Determines whether the component's hot-tracked state is set.

Return Value:

Returns true if the component is hot-tracked; otherwise, returns false.

Overrides:

isHot() in UIComponent.

See Also: setHot

isIndeterminate

public boolean isIndeterminate();

Determines whether the component's indeterminate state is set.

Return Value:

Returns true if the component is indeterminate; otherwise, returns false.

Overrides:

isIndeterminate() in UIComponent.

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

Overrides:

isInvalidating() in UIComponent.

isNotified

public boolean isNotified();

Determines whether the component's notified state is set.

Return Value:

Returns true if the component is notified; otherwise, returns false.

Overrides:

isNotified() in UIComponent.

See Also: addNotify, removeNotify

isPressed

public boolean isPressed();

Determines whether the component's pressed state is set.

Return Value:

Returns true if the component is pressed; otherwise, returns false.

Overrides:

isPressed() in UIComponent.

See Also: setPressed

isRedrawing

public boolean isRedrawing();

Determines whether the component will be redrawn when a paint request is made.

Return Value:

Returns true if the redrawing state is set; otherwise, returns false.

Overrides:

isRedrawing() in UIComponent.

See Also: setRedrawing

isSelected

public boolean isSelected();

Determines whether the component's selected state is set.

Return Value:

Returns true if the component is selected; otherwise, returns false.

Overrides:

isSelected() in UIComponent.

See Also: setSelected

isValid

public boolean isValid();

Determines whether the component is valid.

Return Value:

Returns true if the component is valid; returns false if invalid.

Overrides:

isValid() in UIComponent.

See Also: setValid

isValid

public boolean isValid();

Determines whether the component is valid.

Return Value:

Returns true if the component is valid; returns false if invalid.

Overrides:

isValid() in UIComponent.

See Also: setValid

isVisible

public boolean isVisible();

Determines whether the component's visible state is set.

Return Value:

Returns true if the component is visible; otherwise, returns false.

Overrides:

isVisible() in UIComponent.

See Also: setVisible

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
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. If there is no listener registered, the processKeyEvent method does nothing.

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. If there is no listener registered, the method returns immediately; otherwise, the event is passed to the child component to process.

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. If there is no listener registered, the processMouseMotionEvent method does nothing.

See Also: addMouseMotionListener

recalcPreferredSize

public void recalcPreferredSize();

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

Return Value:

No return value.

Overrides:

recalcPreferredSize() in UIComponent.

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.

Overrides:

removeFocusListener(IUIFocusListener) in UIComponent.

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.

Overrides:

removeKeyListener(IUIKeyListener) in UIComponent.

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.

Overrides:

removeMouseListener(IUIMouseListener) in UIComponent.

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.

Overrides:

removeMouseMotionListener(IUIMouseMotionListener) in UIComponent.

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 the removeNotify method of the superclass.

Overrides:

removeNotify() in UIComponent.

See Also: addNotify

setBackground

public void setBackground(Color color);

Sets the component's background color.

Return Value:

No return value.

ParameterDescription
color The background color for the component.

Overrides:

setBackground(Color) in UIComponent.

See Also: getBackground

setChecked

public void setChecked(boolean on);

Sets or clears the checked state of the component.

Return Value:

No return value.

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

Overrides:

setChecked(boolean) in UIComponent.

See Also: isChecked

setCursor

public void setCursor(Cursor cursor);

Sets the component's cursor.

Return Value:

No return value.

ParameterDescription
cursor The cursor for the component.

Overrides:

setCursor(Cursor) in UIComponent.

See Also: getCursor

setEnabled

public void setEnabled(boolean on);

Sets or clears the enabled state of the component.

Return Value:

No return value.

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

Overrides:

setEnabled(boolean) in UIComponent.

See Also: isEnabled

setFlags

public void setFlags(int flags);

Sets the user-defined bits for the component.

Return Value:

No return value.

ParameterDescription
flags The user-defined settings for the component. You can set any bit in the mask 0xFFF00000.

Overrides:

setFlags(int) in UIComponent.

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

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 component receives or loses focus.

Overrides:

setFocused(boolean) in UIComponent.

See Also: isFocused

setFont

public void setFont(Font font);

Sets the component's font.

Return Value:

No return value.

ParameterDescription
font The font for the component.

Overrides:

setFont(Font) in UIComponent.

See Also: getFont

setForeground

public void setForeground(Color color);

Sets the component's foreground color.

Return Value:

No return value.

ParameterDescription
color The foreground color for the component.

Overrides:

setForeground(Color) in UIComponent.

See Also: getForeground

setHot

public void setHot(boolean on);

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

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

Overrides:

setHot(boolean) in UIComponent.

See Also: isHot

setIndeterminate

public void setIndeterminate(boolean on);

Sets or clears the indeterminate state of the component.

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.

Overrides:

setIndeterminate(boolean) in UIComponent.

See Also: isIndeterminate, setChecked

setIndex

public void setIndex(int index);

Sets the index of the component within its parent container.

ParameterDescription
index The index for the component.

Overrides:

setIndex(int) in UIComponent.

See Also: getIndex

setInvalidating

public void setInvalidating(boolean on);

Sets the invalidating state of this object.

Return Value:

No return value.

ParameterDescription
on Sets the invalidating state to true or false.

Overrides:

setInvalidating(boolean) in UIComponent.

setParent

public void setParent(IUIContainer parent);

Sets the component's parent. If the component already has a parent, it is removed from that parent's hierarchy.

Return Value:

No return value.

ParameterDescription
parent The new parent container for the component.

Overrides:

setParent(IUIContainer) in UIComponent.

See Also: getParent

setPressed

public void setPressed(boolean on);

Sets or clears the pressed state of the component.

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

Overrides:

setPressed(boolean) in UIComponent.

See Also: isPressed

setRedrawing

public void setRedrawing(boolean on);

Sets or clears the redrawing state of the component. If the redrawing state is set, the component will be redrawn when a paint request is made. If the redrawing state is cleared, the component will not be redrawn.

Return Value:

No return value.

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

Overrides:

setRedrawing(boolean) in UIComponent.

See Also: isRedrawing

setSelected

public void setSelected(boolean on);

Sets or clears the selected state of the component.

Return Value:

No return value.

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

Overrides:

setSelected(boolean) in UIComponent.

See Also: isSelected

setValid

public void setValid(boolean valid);

Sets or clears the valid state of the component.

Return Value:

No return value.

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

Overrides:

setValid(boolean) in UIComponent.

See Also: isValid

setVisible

public void setVisible(boolean show);

Sets or clears the visible state of the component.

Return Value:

No return value.

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

Overrides:

setVisible(boolean) in UIComponent.

See Also: isVisible

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