Ascent Phase Corp.

org.ascentphase.suit
Class ScrollList

java.lang.Object
  |
  +--org.ascentphase.suit.Widget
        |
        +--org.ascentphase.suit.ScrollList

public class ScrollList
extends Widget

A selection list that allows a user to select one choice amongst many that are available. Currently, the component supports only one selection. When the user selects a different item from the currently active item, the component will generate a Command event. When a Command event is received, the developer should call the ScrollList's getSelectedItem() method to determine which item is the currently selected item.

Version:
Author:
huyd

Field Summary
protected  int height
           
protected  org.ascentphase.suit.ItemList itemList
           
protected  int rows
           
protected  int width
           
 
Fields inherited from class org.ascentphase.suit.Widget
cmdToThrow
 
Constructor Summary
ScrollList(org.ascentphase.suit.ItemList items, int visibleRows, int width)
          Creates a list with the given ItemList.
ScrollList(java.lang.String[] items, int visibleRow, int width)
          Creates a list with the given array of Strings.
ScrollList(java.util.Vector items, int visibleRow, int width)
          Creates a list with the given Strings in the Vector.
 
Method Summary
 boolean contains(int x, int y)
          Returns whether the given coordinate lies within this widget's area of interest.
 int getIndexOf(java.lang.String text)
          Returns the index of the option with the given text.
 int getSelectedIndex()
          Return the selected row.
 boolean isItemSelected(int idx)
          Returns whether the given item index is selected.
 void paint(Graphics g)
          Draws the widget.
 Command pointerReleased(int x, int y)
          Method called by the widget's containing Panel when a pointer is released over the widget area.
 void setFirstVisibleIndex(int idx)
          Sets the first option that is visible on the scroll list.
 void setSelectedIndex(int row)
          Sets the option at the given index as the active option.
 
Methods inherited from class org.ascentphase.suit.Widget
getCommand, keyPressed, keyReleased, pointerDragged, pointerPressed, setCommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

itemList

protected org.ascentphase.suit.ItemList itemList

rows

protected int rows

width

protected int width

height

protected int height
Constructor Detail

ScrollList

public ScrollList(org.ascentphase.suit.ItemList items,
                  int visibleRows,
                  int width)
Creates a list with the given ItemList.

Parameters:
items - Vector of Strings.
visibleRows - number of rows to display in the list.
width - the width in pixel of the list box.

ScrollList

public ScrollList(java.util.Vector items,
                  int visibleRow,
                  int width)
Creates a list with the given Strings in the Vector.

Parameters:
items - Vector of Strings.
width - the width in pixel of the list box.

ScrollList

public ScrollList(java.lang.String[] items,
                  int visibleRow,
                  int width)
Creates a list with the given array of Strings.

Parameters:
items - Vector of Strings.
width - the width in pixel of the list box.
Method Detail

paint

public void paint(Graphics g)
Draws the widget.

Specified by:
paint in class Widget
Parameters:
g - the Graphics object to draw with.

getSelectedIndex

public int getSelectedIndex()
Return the selected row.


setSelectedIndex

public void setSelectedIndex(int row)
Sets the option at the given index as the active option.

Parameters:
row - the zero-based index of the option.

getIndexOf

public int getIndexOf(java.lang.String text)
Returns the index of the option with the given text.

Parameters:
text - the String value of the option.
Returns:
the index of the option with the given text, -1 if does not exist.

contains

public boolean contains(int x,
                        int y)
Description copied from class: Widget
Returns whether the given coordinate lies within this widget's area of interest. The coordinate is relative to this widget's coordinate system. This method should return true if the coordinate given is of interest to the widget and the widget wishes to receive the keyXXX events and the pointerXXX events.

Overrides:
contains in class Widget
Parameters:
x - the x coordinate.
y - the y coordinate.

pointerReleased

public Command pointerReleased(int x,
                               int y)
Description copied from class: Widget
Method called by the widget's containing Panel when a pointer is released over the widget area. By default, if this method is not over-ridden, it returns null to indicate no Command event.

Overrides:
pointerReleased in class Widget
Parameters:
x - the x-coordinate relative to the widget's origin.
y - the y-coordinate relative to the widget's origin.
Returns:
a Command event to notify any listeners, or null if none.

isItemSelected

public boolean isItemSelected(int idx)
Returns whether the given item index is selected.

Returns:
true if selected, otherwise false.

setFirstVisibleIndex

public void setFirstVisibleIndex(int idx)
Sets the first option that is visible on the scroll list.


Ascent Phase Corp.

Copyright © 2002 Ascent Phase Corp. All Rights Reserved.