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 Name | Property Type | Description |
Row | String[] |
MultiList row content. |
SelectedObjects | Object[] |
A list of column items of the selected row. |
Header | String[] |
Column headers. |
RowCount | int (Readonly) |
Number of rows. |
MultiList generates the following events:
Event Type | Event ID | Generated |
Description |
ObjActionEvent | ActionEvent.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. |
ItemEvent | ItemEvent.SELECTED |
Row selected |
ItemEvent.getItem() and ItemEvent.getStateChange() contain an
Integer and actual value of the row number. |
ItemEvent | ItemEvent.DESELECTED |
Row deselected. |
ItemEvent.getItem() and ItemEvent.getStateChange() contain an
Integer and actual value of the row number. |
-
eventMgr
- EventMgr object handles added event processing and dispatching.
-
MultiList()
- Construct an empty list, with zero row and column.
-
MultiList(int, int)
- Construct a MultiList widget with ncol fields and each with w
character wide.
-
MultiList(int, int, int)
- Construct a MultiList widget with nrow rows, ncol fields, and each
fields with width of w characters.
-
MultiList(int, int[])
- Construct a MultiList widget with nrow rows, and the same number of
fields as the w[] length.
-
MultiList(int[])
- Construct a MultiList widget with the same number of fields as the
length of w[].
-
addActionListener(ActionListener)
- Add an action listener.
-
addItemListener(ItemListener)
- Add an item listener.
-
addRow(String[])
- Add a row to the list.
-
addRow(String[], Image)
- Add a row to the list.
-
clearHeader()
- Remove the header row.
-
clearRows()
- Remove all rows from the list.
-
getRow(int)
- Return the row value at the specified index.
-
getRowCount()
- Return the total number of rows in the list.
-
getSelectedObjects()
- Get the selected items on the selected row.
-
getSelectedRow()
- Return the row number of the selected row.
-
locateRow(int, int)
- Locate the row where the point falls into.
-
makeVisible(int)
- Make the specified row visible.
-
processActionEvent(ActionEvent)
- Process and dispatch action event.
-
processEvent(AWTEvent)
- Process and dispatch event.
-
processItemEvent(ItemEvent)
- Process and dispatch item event.
-
removeActionListener(ActionListener)
- Remove an action listener.
-
removeItemListener(ItemListener)
- Remove an item listener.
-
removeRow(int)
- Remove the specified row.
-
select(int)
- Select the specified row.
-
setCols(int[])
- Set the number of columns and the column width.
-
setHeader(String[])
- Add a header row to the list.
-
setRow(int, String[])
- Set the specified row to the row supplied.
-
setRow(int, String[], Image)
- Set the specified row to the row supplied.
-
setScreenRows(int)
- Set the preferred number of rows on screen.
eventMgr
protected EventMgr eventMgr
- EventMgr object handles added event processing and dispatching.
MultiList
public MultiList()
- Construct an empty list, with zero row and column.
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.
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.
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.
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.
setScreenRows
public synchronized void setScreenRows(int nrow)
- Set the preferred number of rows on screen.
- Parameters:
- nrow - number of rows.
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.
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.
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.
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.
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.
clearHeader
public void clearHeader()
- Remove the header row.
removeRow
public void removeRow(int pos)
- Remove the specified row.
- Parameters:
- pos - row number.
clearRows
public void clearRows()
- Remove all rows from the list. This function will reset all
parameters to the initial state.
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.
getSelectedRow
public int getSelectedRow()
- Return the row number of the selected row.
- Parameters:
- return - row number of the selected row.
select
public void select(int row)
- Select the specified row. To select rows, pass -1 to select().
- Parameters:
- row - row number.
getRowCount
public int getRowCount()
- Return the total number of rows in the list.
- Returns:
- number of rows.
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.
getSelectedObjects
public Object[] getSelectedObjects()
- Get the selected items on the selected row.
- Returns:
- selected items.
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.
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.
addActionListener
public void addActionListener(ActionListener listener)
- Add an action listener.
- Parameters:
- listener - action listener.
removeActionListener
public void removeActionListener(ActionListener listener)
- Remove an action listener.
- Parameters:
- listener - action listener.
addItemListener
public void addItemListener(ItemListener listener)
- Add an item listener.
- Parameters:
- listener - item listener.
removeItemListener
public void removeItemListener(ItemListener listener)
- Remove an item listener.
- Parameters:
- listener - item listener.
processEvent
public void processEvent(AWTEvent e)
- Process and dispatch event.
- Parameters:
- e - event object.
- Overrides:
- processEvent in class Container
processActionEvent
public void processActionEvent(ActionEvent e)
- Process and dispatch action event.
- Parameters:
- e - action event.
processItemEvent
public void processItemEvent(ItemEvent e)
- Process and dispatch item event.
- Parameters:
- e - item event.
All Packages Class Hierarchy This Package Previous Next Index