All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class tea.set.MultiList

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----tea.set.MultiList

public class MultiList
extends Panel
implements ItemSelectable
MultiList widget is a more sophisticated version of List widget. Each item of the MultiList widget is a row, which is a list of fields. A header row can be added to the MultiList widget. The operations supported by the MultiList widget is very similar to the List widget. Users can select a row or scroll through the list. A single click on a row selects the row and generates an ItemEvent.SELECTED event. A double click on a row selects the row and generates an ActionEvent.ACTION_PERFORMED event in addition to the ItemEvent. If a row is already selected, a single click on the row deselects the row and generates an ItemEvent.DESELECTED event. For ItemEvent the item points to an Integer of the row number selected or deselected. An action event is wrapped in ObjActionEvent object, with ObjActionEvent.getObject() pointing to an Integer of the row number.

The display of the scrollbar is automatic. It is shown only when necessary. An optional image can be attached to a row. If an image exists, it will be displayed at the lefthand side of the row.

Known Bug: AWT Scrollbar is highly buggy. It exhibits different behaviors in different environment (JDK, Netscape, ...) and different versions (1.01, 1.02, ...). To make sure all area are always shown, the scrollbar value may appear to to too large, which will cause excessive scrolling at the end.

MultiList supports the following properties:
Property NameProperty TypeDescription
RowString[] MultiList row content.
SelectedObjectsObject[] A list of column items of the selected row.
HeaderString[] Column headers.
RowCountint (Readonly) Number of rows.

MultiList generates the following events:
Event TypeEvent IDGenerated Description
ObjActionEventActionEvent.ACTION_PERFORMED Mouse double click on a row. ActionEvent.getActionCommand() contains the string representation of the row number. ObjActionEvent.getObject() contains an Integer of the row number.
ItemEventItemEvent.SELECTED Row selected ItemEvent.getItem() and ItemEvent.getStateChange() contain an Integer and actual value of the row number.
ItemEventItemEvent.DESELECTED Row deselected. ItemEvent.getItem() and ItemEvent.getStateChange() contain an Integer and actual value of the row number.


Variable Index

 o eventMgr
EventMgr object handles added event processing and dispatching.

Constructor Index

 o MultiList()
Construct an empty list, with zero row and column.
 o MultiList(int, int)
Construct a MultiList widget with ncol fields and each with w character wide.
 o MultiList(int, int, int)
Construct a MultiList widget with nrow rows, ncol fields, and each fields with width of w characters.
 o MultiList(int, int[])
Construct a MultiList widget with nrow rows, and the same number of fields as the w[] length.
 o MultiList(int[])
Construct a MultiList widget with the same number of fields as the length of w[].

Method Index

 o addActionListener(ActionListener)
Add an action listener.
 o addItemListener(ItemListener)
Add an item listener.
 o addRow(String[])
Add a row to the list.
 o addRow(String[], Image)
Add a row to the list.
 o clearHeader()
Remove the header row.
 o clearRows()
Remove all rows from the list.
 o getRow(int)
Return the row value at the specified index.
 o getRowCount()
Return the total number of rows in the list.
 o getSelectedObjects()
Get the selected items on the selected row.
 o getSelectedRow()
Return the row number of the selected row.
 o locateRow(int, int)
Locate the row where the point falls into.
 o makeVisible(int)
Make the specified row visible.
 o processActionEvent(ActionEvent)
Process and dispatch action event.
 o processEvent(AWTEvent)
Process and dispatch event.
 o processItemEvent(ItemEvent)
Process and dispatch item event.
 o removeActionListener(ActionListener)
Remove an action listener.
 o removeItemListener(ItemListener)
Remove an item listener.
 o removeRow(int)
Remove the specified row.
 o select(int)
Select the specified row.
 o setCols(int[])
Set the number of columns and the column width.
 o setHeader(String[])
Add a header row to the list.
 o setRow(int, String[])
Set the specified row to the row supplied.
 o setRow(int, String[], Image)
Set the specified row to the row supplied.
 o setScreenRows(int)
Set the preferred number of rows on screen.

Variables

 o eventMgr
 protected EventMgr eventMgr
EventMgr object handles added event processing and dispatching.

Constructors

 o MultiList
 public MultiList()
Construct an empty list, with zero row and column.

 o MultiList
 public MultiList(int ncol,
                  int w)
Construct a MultiList widget with ncol fields and each with w character wide. The width of the field is only used as a preferred value, and may change depending on the screen size.

Parameters:
ncol - number of columns.
width - of column in characters.
 o MultiList
 public MultiList(int w[])
Construct a MultiList widget with the same number of fields as the length of w[]. The width for each field is taken from w[]. The width values are used to calculate the preferred size, but may change with screen size. If the preferred width can't be met, the width in the w[] will be used to distribute space proportional to the values specified for each field.

Parameters:
width - array of columns.
 o MultiList
 public MultiList(int nrow,
                  int ncol,
                  int w)
Construct a MultiList widget with nrow rows, ncol fields, and each fields with width of w characters. All values specified are advisory and may change depending on the assigned size for this widget.

Parameters:
nrow - number of visible rows.
ncol - number of columns.
width - of column in characters.
 o MultiList
 public MultiList(int nrow,
                  int w[])
Construct a MultiList widget with nrow rows, and the same number of fields as the w[] length. The width for each field is specified in w[] array.

Parameters:
nrow - number of visible rows.
w - column width array.

Methods

 o setScreenRows
 public synchronized void setScreenRows(int nrow)
Set the preferred number of rows on screen.

Parameters:
nrow - number of rows.
 o addRow
 public void addRow(String row[])
Add a row to the list. Row is an array of Strings. If the number of strings in the array is less than the number of field of this list, the array will be padded with empty strings.

Parameters:
row - an array with each item corresponds to a column in the row.
 o addRow
 public void addRow(String row[],
                    Image img)
Add a row to the list. Row is an array of Strings. If the number of strings in the array is less than the number of field of this list, the array will be padded with empty strings. An image can be supplied to be displayed at the left side of the row.

Parameters:
row - an array with each item corresponds to a column in the row.
img - image icon for the row.
 o setCols
 public void setCols(int w[])
Set the number of columns and the column width. This method should normally be called before the data is populated.

Parameters:
w - column width.
 o setRow
 public void setRow(int pos,
                    String row[])
Set the specified row to the row supplied. If the position is out of range, this call is ignored. Row is an array of Strings. If the number of strings in the array is less than the number of field of this list, the array will be padded with empty strings.

Parameters:
row - an array with each item corresponds to a column in the row.
pos - row number.
 o setRow
 public void setRow(int pos,
                    String row[],
                    Image img)
Set the specified row to the row supplied. If the position is out of range, this call is ignored. Row is an array of Strings. If the number of strings in the array is less than the number of field of this list, the array will be padded with empty strings. An image can be supplied to be displayed at the left side of the row.

Parameters:
row - an array with each item corresponds to a column in the row.
img - image icon for the row.
pos - row number.
 o clearHeader
 public void clearHeader()
Remove the header row.

 o removeRow
 public void removeRow(int pos)
Remove the specified row.

Parameters:
pos - row number.
 o clearRows
 public void clearRows()
Remove all rows from the list. This function will reset all parameters to the initial state.

 o setHeader
 public void setHeader(String row[])
Add a header row to the list. Parameter is same as addRow().

Parameters:
row - an array with each item corresponds to a column in the row.
 o getSelectedRow
 public int getSelectedRow()
Return the row number of the selected row.

Parameters:
return - row number of the selected row.
 o select
 public void select(int row)
Select the specified row. To select rows, pass -1 to select().

Parameters:
row - row number.
 o getRowCount
 public int getRowCount()
Return the total number of rows in the list.

Returns:
number of rows.
 o getRow
 public String[] getRow(int idx)
Return the row value at the specified index.

Parameters:
idx - row number.
Returns:
a row which is an array of columns.
 o getSelectedObjects
 public Object[] getSelectedObjects()
Get the selected items on the selected row.

Returns:
selected items.
 o makeVisible
 public void makeVisible(int row)
Make the specified row visible. This will cause the specified row to be scrolled to the screen if it's not currently visible.

Parameters:
row - row number.
 o locateRow
 public int locateRow(int x,
                      int y)
Locate the row where the point falls into.

Parameters:
x - x coordinate.
y - y coordinate.
Returns:
row number.
 o addActionListener
 public void addActionListener(ActionListener listener)
Add an action listener.

Parameters:
listener - action listener.
 o removeActionListener
 public void removeActionListener(ActionListener listener)
Remove an action listener.

Parameters:
listener - action listener.
 o addItemListener
 public void addItemListener(ItemListener listener)
Add an item listener.

Parameters:
listener - item listener.
 o removeItemListener
 public void removeItemListener(ItemListener listener)
Remove an item listener.

Parameters:
listener - item listener.
 o processEvent
 public void processEvent(AWTEvent e)
Process and dispatch event.

Parameters:
e - event object.
Overrides:
processEvent in class Container
 o processActionEvent
 public void processActionEvent(ActionEvent e)
Process and dispatch action event.

Parameters:
e - action event.
 o processItemEvent
 public void processItemEvent(ItemEvent e)
Process and dispatch item event.

Parameters:
e - item event.

All Packages  Class Hierarchy  This Package  Previous  Next  Index