Package com.ms.ui Previous
Previous
Contents
Contents
Index
Index
Next
Next

Class UISelector

Constructors , Methods

public abstract class UISelector extends UIPanel implements IUISelector,
TimerListener 
{
  // Constructors
  public UISelector();
  public UISelector(int selMode);

  // Methods
  public Component find(String prefix);
  public Component find(String prefix, boolean fromFocus);
  public int getRoleCode();
  public int getStateCode();
  public void setSelected(boolean on);

  public boolean gotFocus(Event e, Object o);
  public boolean lostFocus(Event e, Object o);
  public boolean keyDown(Event e, int key);
  public boolean mouseDown(Event e, int x, int y);
  public boolean mouseDrag(Event e, int x, int y);

  public int getSelectedIndex();
  public int[] getSelectedIndices();
  public Component getSelectedItem();
  public Component[] getSelectedItems();
  public int getSelectionMode();

  public void setSelectedIndex(int index);
  public void setSelectedIndex(int index, boolean notify);
  public void setSelectedIndices(int indices[]);
  public void setSelectedIndices(int indices[], boolean notify);
  public void setSelectedItem(Component comp);
  public void setSelectedItem(Component comp, boolean notify);
  public void setSelectedItems(Component comps[]);
  public void setSelectedItems(Component comps[], boolean notify);
  public void setSelectionMode(int selMode);

  public void selectIndex(int index);
  public void selectIndex(int index, boolean on);
  public void selectIndex(int index, boolean on, boolean notify);
  public void selectItem(Component comp);
  public void selectItem(Component comp, boolean on);
  public void selectItem(Component comp, boolean on, boolean notify);

  public void timeTriggered(TimerEvent te);

}

An abstract class that manages a selector control. UISelector supports SINGLESELECT, MULTISELECT, and EXTENDSELECT selection modes. UISelector provides methods to search for an item in the selector control and to determine and set the currently selected item.

The following diagram shows the classes that extend UISelector.

UISelector
|
+--UIList
|
+--UITabList
|
+--UITree


Constructors


UISelector

public UISelector();

Creates a selector control with the SINGLESELECT selection mode.


UISelector

public UISelector(int selMode);

Creates a selector control with the specified selection mode.

ParameterDescription
selMode The selection mode. Specify SINGLESELECT, MULTISELECT, or EXTENDSELECT.

Remarks:

If an undefined selection mode is specified, an IllegalArgumentException is thrown.


Methods


find

public Component find(String prefix);

Searches the selector control for an object whose name begins with the specified prefix, starting at the first item in the control.

Return Value:

Returns the first matching component, or null if no component is found.

ParameterDescription
prefix The prefix string to search for.


find

public Component find(String prefix, boolean fromFocus);

Searches the selector control for an object whose name begins with the specified prefix; the search can optionally start at the item that currently has focus.

Return Value:

Returns the first matching component, or null if no component is found.

ParameterDescription
prefix The prefix string to search for.
fromFocus If true, the search begins from the item with focus; otherwise, the search begins at the first item in the control.


getRoleCode

public int getRoleCode();

Retrieves the role of the selector control.

Return Value:

Returns the ROLE_SYSTEM code that best describes the role of the control.

Remarks:

This method returns the ROLE_SYSTEM_LIST code.


getSelectedIndex

public int getSelectedIndex();

Retrieves the zero-based index of the currently selected item.

Return Value:

Returns the index of the selected item, or -1 if no item is selected.

Remarks:

This method implements getSelectedIndex in the IUISelector interface, and is only valid for single-selection controls. If the selection mode is MULTISELECT or EXTENDSELECT, this method always returns -1. For multiple- or extended-selection controls, call getSelectedIndices.


getSelectedIndices

public int[] getSelectedIndices();

Retrieves the zero-based indices of all currently selected items.

Return Value:

Returns an array of the indices of the selected items, or null if no item is selected.

Remarks:

This method implements getSelectedIndices in the IUISelector interface. If the control's selection mode is SINGLESELECT, you can also call getSelectedIndex.


getSelectedItem

public Component getSelectedItem();

Retrieves the currently selected item.

Return Value:

Returns the selected component, or null if no component is selected.

Remarks:

This method implements getSelectedItem in the IUISelector interface, and is only valid for single-selection controls. If the selection mode is MULTISELECT or EXTENDSELECT, this method always returns null. For multiple- or extended-selection controls, call getSelectedItems.


getSelectedItems

public Component[] getSelectedItems();

Retrieves all currently selected items.

Return Value:

Returns an array of the selected components, or null if no component is selected.

Remarks:

This method implements getSelectedItems in the IUISelector interface. If the control's selection mode is SINGLESELECT, you can also call getSelectedItem.


getSelectionMode

public int getSelectionMode();

Retrieves the selection mode of the control.

Return Value:

Returns one of the following three selection modes: SINGLESELECT, MULTISELECT, or EXTENDSELECT.

Remarks:

This method implements getSelectionMode in the IUISelector interface.


getStateCode

public int getStateCode();

Retrieves the state of the selector control.

Return Value:

Returns the combination of STATE_SYSTEM codes that best describes the state of the control.

Remarks:

If the selector control has the MULTISELECT style set, the returned code contains the STATE_SYSTEM_MULTISELECTABLE flag. If the EXTENDSELECT style is set, the returned code contains the STATE_SYSTEM_EXTSELECTABLE flag.


gotFocus

public boolean gotFocus(Event e, Object o);

Reacts to the selector control receiving focus.

Return Value:

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

ParameterDescription
e The event posted to the control.
o The object that posted the event (always null).


keyDown

public boolean keyDown(Event e, int key);

Handles keyboard navigation for the selector control.

Return Value:

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

ParameterDescription
e The event posted to the control.
key The key that has been pressed.

Remarks:

This method is called when the control has focus and a key is pressed. keyDown responds to the following key values.
Key Action
HOME, END, PAGEUP, PAGEDOWN, all ARROW keys Navigates through the items in the control.
BACKSPACE Clears the previous key pressed during an incremental type search.
ESC Stops an incremental type search.
All other keys Begins an incremental type search for a component that begins with the characters pressed (limited by a timer). If a match is found, that component receives focus.


lostFocus

public boolean lostFocus(Event e, Object o);

Reacts to the selector control losing focus.

Return Value:

Returns false.

ParameterDescription
e The event posted to the control.
o The object that posted the event (always null).


mouseDown

public boolean mouseDown(Event e, int x, int y);

Determines if an item in the selector control was double-clicked, and, if so, generates an action event for that item.

Return Value:

Always returns false.

ParameterDescription
e The event posted to the control.
x The x coordinate of the event.
y The y coordinate of the event.


mouseDrag

public boolean mouseDrag(Event e, int x, int y);

Reacts to the mouse being dragged across items in the selector control.

Return Value:

Always returns false.

ParameterDescription
e The event posted to the control.
x The x coordinate of the event.
y The y coordinate of the event.


selectIndex

public void selectIndex(int index);

Sets the selected state of the component at the specified index, and sets the control's selection to this component. By default, a LIST_SELECT event is not generated.

Return Value:

No return value.

ParameterDescription
index The zero-based index of the item to be selected.

Remarks:

This method implements selectIndex in the IUISelector interface. To toggle the item's selected state, call selectIndex with the boolean parameter. To generate a LIST_SELECT event, call selectIndex with the boolean parameter set to true.


selectIndex

public void selectIndex(int index, boolean on);

Sets or clears the selected state of the component at the specified index, and sets the control's selection to this component. By default, a LIST_SELECT event is not generated.

Return Value:

No return value.

ParameterDescription
index The zero-based index of the item to be selected or de-selected.
on If true, the item's selected state is set; otherwise, it is cleared.

Remarks:

This method implements selectIndex in the IUISelector interface. To generate a LIST_SELECT event, call selectIndex with the boolean parameter set to true.


selectIndex

public void selectIndex(int index, boolean on, boolean notify);

Sets or clears the selected state of the component at the specified index, and sets the control's selection to this component. A LIST_SELECT event is optionally generated.

Return Value:

No return value.

ParameterDescription
index The zero-based index of the item to be selected or de-selected.
on If true, the item's selected state is set; otherwise, it is cleared.
notify If true, a LIST_SELECT event will be generated; otherwise, a LIST_SELECT event will not be generated.

Remarks:

This method implements selectIndex in the IUISelector interface.


selectItem

public void selectItem(Component comp);

Sets the selected state of the specified component, and sets the control's selection to this component. By default, a LIST_SELECT event is not generated.

Return Value:

No return value.

ParameterDescription
index The item to be selected.

Remarks:

This method implements selectItem in the IUISelector interface. To toggle the item's selected state, call selectItem with the boolean parameter. To generate a LIST_SELECT event, call selectItem with the boolean parameter set to true.


selectItem

public void selectItem(Component comp, boolean on);

Sets or clears the selected state of the specified component, and sets the control's selection to this component. By default, a LIST_SELECT event is not generated.

Return Value:

No return value.

ParameterDescription
index The item to be selected or de-selected.
on If true, the item's selected state is set; otherwise, it is cleared.

Remarks:

This method implements selectItem in the IUISelector interface. To generate a LIST_SELECT event, call selectItem with the boolean parameter set to true.


selectItem

public void selectItem(Component comp, boolean on, boolean notify);

Sets or clears the selected state of the specified component, and sets the control's selection to this component. A LIST_SELECT event is optionally generated.

Return Value:

No return value.

ParameterDescription
comp The item to be selected or de-selected.
on If true, the item's selected state is set; otherwise, it is cleared.
notify If true, a LIST_SELECT event will be generated; otherwise, a LIST_SELECT event will not be generated.

Remarks:

This method implements selectItem in the IUISelector interface.


setSelected

public void setSelected(boolean on);

Sets or clears the selected state of the selector control.

Return Value:

No return value.

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


setSelectedIndex

public void setSelectedIndex(int index);

Sets the selection to the component at the specified index. By default, a LIST_SELECT event is not generated.

Return Value:

No return value.

ParameterDescription
index The zero-based index of the item to be selected.

Remarks:

This method implements setSelectedIndex in the IUISelector interface, and clears any previous selection. If the control's selection mode is MULTISELECT or EXTENDSELECT, you can also call setSelectedIndices to select multiple items at a time.

To generate a LIST_SELECT event, call setSelectedIndex with the boolean parameter set to true.


setSelectedIndex

public void setSelectedIndex(int index, boolean notify);

Sets the selection to the component at the specified index, and optionally generates a LIST_SELECT event.

Return Value:

No return value.

ParameterDescription
index The zero-based index of the item to be selected.
notify If true, a LIST_SELECT event will be generated; otherwise, a LIST_SELECT event will not be generated.

Remarks:

This method implements setSelectedIndex in the IUISelector interface, and clears any previous selection. If the control's selection mode is MULTISELECT or EXTENDSELECT, you can also call setSelectedIndices to select multiple items at a time.


setSelectedIndices

public void setSelectedIndices(int indices[]);

Sets the selection to the components at the specified indices. By default, LIST_SELECT events are not gerenated.

Return Value:

No return value.

ParameterDescription
indices An array containing the indices of the items to be selected.

Remarks:

This method implements setSelectedIndices in the IUISelector interface, and clears any previous selection. If the control's selection mode is SINGLESELECT, you can also call setSelectedIndex.

To generate LIST_SELECT events, call setSelectedIndices with the boolean parameter set to true.


setSelectedIndices

public void setSelectedIndices(int indices[], boolean notify);

Sets the selection to the components at the specified indices, and optionally generates LIST_SELECT events.

Return Value:

No return value.

ParameterDescription
indices An array containing the indices of the items to be selected.
notify If true, LIST_SELECT events will be generated; otherwise, LIST_SELECT events will not be generated.

Remarks:

This method implements setSelectedIndices in the IUISelector interface, and clears any previous selection. If the control's selection mode is SINGLESELECT, you can also call setSelectedIndex.


setSelectedItem

public void setSelectedItem(Component comp);

Sets the selection to the specified component. By default, a LIST_SELECT event is not generated.

Return Value:

No return value.

ParameterDescription
comp The item to be selected. If this component is not an immediate child of the selector control, an IllegalArgumentException is thrown.

Remarks:

This method implements setSelectedItem in the IUISelector interface, and clears any previous selection. If the control's selection mode is MULTISELECT or EXTENDSELECT, you can also call setSelectedItems to select multiple items at a time.

To generate a LIST_SELECT event, call setSelectedItem with the boolean parameter set to true.


setSelectedItem

public void setSelectedItem(Component comp, boolean notify);

Sets the selection to the specified component, and optionally generates a LIST_SELECT event.

Return Value:

No return value.

ParameterDescription
comp The item to be selected. If this component is not an immediate child of the selector control, an IllegalArgumentException is thrown.
notify If true, a LIST_SELECT event will be generated; otherwise, a LIST_SELECT event will not be generated.

Remarks:

This method implements setSelectedItem in the IUISelector interface, and clears any previous selection. If the control's selection mode is MULTISELECT or EXTENDSELECT, you can also call setSelectedItems to select multiple items at a time.


setSelectedItems

public void setSelectedItems(Component comps[]);

Sets the selection to the specified components. By default, LIST_SELECT events are not generated.

Return Value:

No return value.

ParameterDescription
comps An array containing the items to be selected. If any component is not an immediate child of the selector control, an IllegalArgumentException is thrown.

Remarks:

This method implements setSelectedItems in the IUISelector interface, and clears any previous selection. If the control's selection mode is SINGLESELECT, you can also call setSelectedItem.

To generate LIST_SELECT events, call setSelectedItems with the boolean parameter set to true.


setSelectedItems

public void setSelectedItems(Component comps[], boolean notify);

Sets the selection to the specified components, and optionally generates LIST_SELECT events.

Return Value:

No return value.

ParameterDescription
comps An array containing the items to be selected. If any component is not an immediate child of the selector control, an IllegalArgumentException is thrown.
notify If true, LIST_SELECT events will be generated; otherwise, LIST_SELECT events will not be generated.

Remarks:

This method implements setSelectedItems in the IUISelector interface, and clears any previous selection. If the control's selection mode is SINGLESELECT, you can also call setSelectedItem.


setSelectionMode

public void setSelectionMode(int selMode);

Sets the selection mode of the control.

Return Value:

No return value.

ParameterDescription
selMode The selection mode for the control. Specify SINGLESELECT, MULTISELECT, or EXTENDSELECT.

Remarks:

This method implements setSelectionMode in the IUISelector interface. If an undefined selection mode is specified, an IllegalArgumentException is thrown.


timeTriggered

public void timeTriggered(TimerEvent te);

Stops an incremental type search of the selector.

Return Value:

No return value.

ParameterDescription
te A TimerEvent object that describes the timer event.

Remarks:

This method implements timeTriggered in the TimerListener interface, and is automatically invoked during keyDown to stop the type search when the timer has expired.



Top© 1997 Microsoft Corporation. All rights reserved. Legal Notices.