All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jclass.bwt.JCList

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----jclass.bwt.JCContainer
                                   |
                                   +----jclass.bwt.JCScrolledWindow
                                           |
                                           +----jclass.bwt.JCList

public class JCList
extends JCScrolledWindow
implements JCListInterface, JCItemSelectable
A scrollable list of text and/or image items.

Behavior

Properties

Name Method
AllowMultipleSelections setAllowMultipleSelections
AutoSelect setAutoSelect
Background setBackground
Batched setBatched
Font setFont
Foreground setForeground
Insets setInsets
Items setItems
PreferredSize setPreferredSize
RowHeight setRowHeight
ScrollbarDisplay setScrollbarDisplay
ScrollbarOffset setScrollbarOffset
SelectedBackground setSelectedBackground
SelectedForeground setSelectedForeground
Spacing setSpacing
UserData setUserData
UserDataList setUserDataList
VisibleRows setVisibleRows

Events

Class Listener Description
JCActionEvent addActionListener Posted when an item is double-clicked, or the ENTER key is hit
JCListEvent addItemListener Posted when an item is clicked or the space key is hit


Constructor Index

 o JCList()
Creates an empty 4-row list.
 o JCList(int, boolean)
Creates an empty list with the specified number of visible rows.
 o JCList(JCVector)
Creates a 4-row list with the specified items.
 o JCList(JCVector, Applet, String)
Creates a 4-row list which reads parameters from the applet's HTML file.
 o JCList(String[], String)
Creates a 4-row list with the specified items and name.

Method Index

 o addActionListener(JCActionListener)
Adds the specified action listener to receive action events from this list.
 o addItem(Object)
Adds the specified item to the end of the list.
 o addItem(Object, int)
Adds or inserts an item to the list.
 o addItemListener(JCItemListener)
Adds the specified item listener to receive item events from this list.
 o allowsMultipleSelections()
Returns true if this list allows multiple selections.
 o clear()
Clears the list.
 o countItems()
Returns the number of items in the list.
 o deleteItem(int)
Deletes an item from the list.
 o deleteItems(int, int)
Delete multiple items from the list.
 o deselect(int)
Deselects the item at the specified row.
 o deselectAll()
Deselects all items.
 o find(Object)
Finds the first row matching the specified item, or BWTEnum.NOTFOUND.
 o getAllowMultipleSelections()
Returns true if this list allows multiple selections.
 o getAutoSelect()
Gets the AutoSelect value.
 o getBatched()
Gets the Batched value.
 o getItem(int)
Gets the item associated with the specified index.
 o getItems()
Gets the list's values.
 o getItemsStrings()
Gets the list's values as a list of Strings.
 o getList()
Gets the internal list.
 o getRowHeight()
Gets the height of each row (pixels).
 o getRows()
Returns the number of visible lines in this list.
 o getSelectedBackground()
Gets the list's SelectedBackground value.
 o getSelectedForeground()
Gets the list's SelectedForeground value.
 o getSelectedIndex()
Gets the selected item on the list or BWTEnum.NOTFOUND if no item is selected.
 o getSelectedIndexes()
Returns the selected indexes on the list, or null if no item is selected.
 o getSelectedItem()
Returns the selected item on the list, or null if no item is selected.
 o getSelectedObjects()
Returns the selected items on the list as Strings, or null if no item is selected.
 o getSpacing()
Gets the spacing between items.
 o getTopRow()
Gets the current top-most visible row.
 o getUserDataList()
Gets the UserDataList value.
 o getViewportHeight()
Sets the work area height to be the list's virtual height.
 o getVisibleIndex()
Gets the row of the item that was last made visible by the method makeVisible.
 o isSelected(int)
Returns true if the item at the specified row has been selected; false otherwise.
 o makeVisible(int)
Forces the item at the specified row to be visible.
 o paintRow(int)
Draws a row.
 o preferredWidth()
Gets the subclass' preferred width (default: 100).
 o remove(String)
Removes the first occurrence of an item from the list.
 o removeActionListener(JCActionListener)
Removes the specified action listener so it no longer receives action events from this list.
 o removeAll()
Removes all items from the list.
 o removeItemListener(JCItemListener)
Removes the specified item listener so it no longer receives item events from this list.
 o replaceItem(Object, int)
Replaces the item at the given row.
 o scrollVertical(JCScrollableInterface, JCAdjustmentEvent, int)
Scrolls the list vertically.
 o select(int)
Selects the item at the specified row, and posts a JCListEvent
 o select(int, boolean)
Selects the item at the specified row.
 o select(Object)
Selects the specified item.
 o select(Object, boolean)
Selects the specified item.
 o setAllowMultipleSelections(boolean)
Sets whether the list allows multiple selections.
 o setAutoSelect(boolean)
If true, the item which currently has focus is also selected (default: false).

HTML param name/value: "AutoSelect"/boolean

 o setBatched(boolean)
If false (default), the component is repainted every time an item is changed.
 o setItems(JCVector)
Sets the list's values as a Vector of objects.

HTML param name/value: "Items"/string list

 o setItems(String[])
Sets the list's values as a list of Strings.
 o setItemsStrings(String[])
Sets the list's values as a list of Strings.
 o setList(JCListComponent)
Replaces the current internal list.
 o setRowHeight(int)
Sets the height of each row (pixels).

HTML param name/value: "RowHeight"/an int, "VARIABLE", or "FONT_HEIGHT"

 o setSelectedBackground(Color)
Sets the background color of selected rows (default: foreground color).

HTML param name/value: "SelectedBackground"/color

 o setSelectedForeground(Color)
Sets the foreground color of selected rows (default: background color).

HTML param name/value: "SelectedForeground"/color

 o setSpacing(int)
Sets the spacing between items (default: 0).
 o setTopRow(int)
Sets the top-most visible row.
 o setUserDataList(Object[])
Sets an application-defined list of objects that are maintained for each item.
 o setVisibleRows(int)
Sets the number of visible rows (default: 4).

Constructors

 o JCList
 public JCList()
Creates an empty 4-row list. No parameters are read from an HTML file.

 o JCList
 public JCList(JCVector items)
Creates a 4-row list with the specified items. No parameters are read from an HTML file.

See Also:
setItems
 o JCList
 public JCList(String items[],
               String name)
Creates a 4-row list with the specified items and name. No parameters are read from an HTML file.

 o JCList
 public JCList(JCVector items,
               Applet applet,
               String name)
Creates a 4-row list which reads parameters from the applet's HTML file.

Parameters:
items - the initial items; each element may be a String, JCString, or any object (in which case the object's toString() method is called to obtain a string)
applet - the applet whose PARAM tags are to be read
name - if this is not null, only parameters preceded by this name are read
See Also:
setItems, getParameter, JCString
 o JCList
 public JCList(int rows,
               boolean multipleSelections)
Creates an empty list with the specified number of visible rows.

Parameters:
rows - the number of items to show (default: 4). If set to BWTEnum.VARIABLE, the list will attempt to show all its items.
multipleSelections - if true, then multiple selections are allowed

Methods

 o getList
 public JCListComponent getList()
Gets the internal list.

 o setList
 public void setList(JCListComponent list)
Replaces the current internal list.

 o preferredWidth
 protected int preferredWidth()
Gets the subclass' preferred width (default: 100).

Overrides:
preferredWidth in class JCScrolledWindow
 o getViewportHeight
 protected int getViewportHeight()
Sets the work area height to be the list's virtual height.

Overrides:
getViewportHeight in class JCScrolledWindow
 o scrollVertical
 protected void scrollVertical(JCScrollableInterface scrollable,
                               JCAdjustmentEvent ev,
                               int value)
Scrolls the list vertically.

Overrides:
scrollVertical in class JCScrolledWindow
 o addItemListener
 public void addItemListener(JCItemListener l)
Adds the specified item listener to receive item events from this list. If the listener implements JCListListener (an JCItemListener subclass), it will be passed JCListEvents.

See Also:
JCItemEvent, JCListEvent, JCListListener
 o removeItemListener
 public void removeItemListener(JCItemListener l)
Removes the specified item listener so it no longer receives item events from this list.

 o addActionListener
 public void addActionListener(JCActionListener l)
Adds the specified action listener to receive action events from this list. Action events occur when a list item is double-clicked.

See Also:
JCActionEvent
 o removeActionListener
 public void removeActionListener(JCActionListener l)
Removes the specified action listener so it no longer receives action events from this list.

See Also:
addActionListener
 o remove
 public synchronized void remove(String item)
Removes the first occurrence of an item from the list.

Throws: IllegalArgumentException
If the item doesn't exist.
See Also:
deleteItem
 o getItems
 public synchronized JCVector getItems()
Gets the list's values.

See Also:
setItems
 o setItems
 public synchronized void setItems(JCVector items)
Sets the list's values as a Vector of objects.

HTML param name/value: "Items"/string list

Parameters:
items - each object may be a String, JCString, or any object (in which case the object's toString() method is called to obtain a string)
See Also:
JCString, toVector
 o setItems
 public synchronized void setItems(String items[])
Sets the list's values as a list of Strings.

 o getItemsStrings
 public synchronized String[] getItemsStrings()
Gets the list's values as a list of Strings.

See Also:
setItems
 o setItemsStrings
 public synchronized void setItemsStrings(String items[])
Sets the list's values as a list of Strings.

 o countItems
 public int countItems()
Returns the number of items in the list.

See Also:
getItem
 o getItem
 public Object getItem(int row)
Gets the item associated with the specified index.

Parameters:
row - the position of the item
See Also:
countItems
 o addItem
 public synchronized void addItem(Object item)
Adds the specified item to the end of the list.

Parameters:
item - the item to be added
 o addItem
 public synchronized void addItem(Object item,
                                  int row)
Adds or inserts an item to the list.

Parameters:
item - the item to be added; this may be a String, JCString, or any object (in which case the object's toString() method is called to obtain a string)
row - the position at which to put the item; if row is -1, or greater than the number of items in the list, the item is added to the end
See Also:
JCString
 o replaceItem
 public synchronized void replaceItem(Object item,
                                      int row)
Replaces the item at the given row.

Parameters:
item - the new value to replace the existing item
row - the position of the item to replace
 o getBatched
 public boolean getBatched()
Gets the Batched value.

See Also:
setBatched
 o setBatched
 public void setBatched(boolean v)
If false (default), the component is repainted every time an item is changed. If set to true, the component is only repainted (if necessary) when the value is again set to false.

 o removeAll
 public synchronized void removeAll()
Removes all items from the list.

Overrides:
removeAll in class Container
See Also:
remove, deleteItems
 o clear
 public synchronized void clear()
Clears the list.

See Also:
deleteItem, deleteItems
 o deleteItem
 public synchronized void deleteItem(int row)
Deletes an item from the list.

 o deleteItems
 public synchronized void deleteItems(int start,
                                      int end)
Delete multiple items from the list.

 o find
 public int find(Object item)
Finds the first row matching the specified item, or BWTEnum.NOTFOUND.

 o getSelectedIndex
 public int getSelectedIndex()
Gets the selected item on the list or BWTEnum.NOTFOUND if no item is selected.

See Also:
select, deselect, isSelected
 o getSelectedIndexes
 public int[] getSelectedIndexes()
Returns the selected indexes on the list, or null if no item is selected.

See Also:
select, deselect, isSelected
 o getSelectedItem
 public Object getSelectedItem()
Returns the selected item on the list, or null if no item is selected.

See Also:
select, deselect, isSelected
 o getSelectedObjects
 public Object[] getSelectedObjects()
Returns the selected items on the list as Strings, or null if no item is selected.

See Also:
select, deselect, isSelected
 o getAutoSelect
 public boolean getAutoSelect()
Gets the AutoSelect value.

See Also:
setAutoSelect
 o setAutoSelect
 public void setAutoSelect(boolean v)
If true, the item which currently has focus is also selected (default: false).

HTML param name/value: "AutoSelect"/boolean

See Also:
select
 o select
 public synchronized void select(int row)
Selects the item at the specified row, and posts a JCListEvent

Parameters:
row - the position of the item to select
See Also:
getSelectedItem, deselect, isSelected, addItemListener
 o select
 public synchronized void select(Object item)
Selects the specified item.

See Also:
getSelectedItem, getSelectedIndex
 o select
 public synchronized void select(Object item,
                                 boolean notify)
Selects the specified item. If allowsMultipleSelections is false, any previously selected rows are deselected.

Parameters:
notify - if true, a JCListEvent is posted.
See Also:
setAllowMultipleSelections, getSelectedItem, deselect, isSelected, addItemListener
 o select
 public synchronized void select(int row,
                                 boolean notify)
Selects the item at the specified row. If allowsMultipleSelections is false, any previously selected rows are deselected.

Parameters:
notify - if true, a JCListEvent is posted.
See Also:
setAllowMultipleSelections, getSelectedItem, deselect, isSelected, addItemListener
 o deselect
 public synchronized void deselect(int row)
Deselects the item at the specified row.

Parameters:
row - the position of the item to deselect
See Also:
select, getSelectedItem, isSelected
 o deselectAll
 public synchronized void deselectAll()
Deselects all items. No events are posted

 o isSelected
 public boolean isSelected(int row)
Returns true if the item at the specified row has been selected; false otherwise.

Parameters:
row - the item to be checked
See Also:
select, deselect, isSelected
 o getSelectedBackground
 public Color getSelectedBackground()
Gets the list's SelectedBackground value.

See Also:
setSelectedBackground
 o setSelectedBackground
 public void setSelectedBackground(Color v)
Sets the background color of selected rows (default: foreground color).

HTML param name/value: "SelectedBackground"/color

See Also:
toColor
 o getSelectedForeground
 public Color getSelectedForeground()
Gets the list's SelectedForeground value.

See Also:
setSelectedForeground
 o setSelectedForeground
 public void setSelectedForeground(Color v)
Sets the foreground color of selected rows (default: background color).

HTML param name/value: "SelectedForeground"/color

See Also:
toColor
 o getRows
 public int getRows()
Returns the number of visible lines in this list.

 o setVisibleRows
 public void setVisibleRows(int v)
Sets the number of visible rows (default: 4). If set to BWTEnum.VARIABLE, the list will attempt to resize itself so that all its items are visible.

HTML param name/value: "VisibleRows"/int

See Also:
setItems
 o getTopRow
 public int getTopRow()
Gets the current top-most visible row.

See Also:
setTopRow
 o setTopRow
 public synchronized void setTopRow(int row)
Sets the top-most visible row.

See Also:
makeVisible
 o allowsMultipleSelections
 public boolean allowsMultipleSelections()
Returns true if this list allows multiple selections.

See Also:
setAllowMultipleSelections
 o getAllowMultipleSelections
 public boolean getAllowMultipleSelections()
Returns true if this list allows multiple selections.

See Also:
setAllowMultipleSelections
 o setAllowMultipleSelections
 public void setAllowMultipleSelections(boolean v)
Sets whether the list allows multiple selections. HTML param name/value: "AllowMultipleSelections"/boolean

See Also:
allowsMultipleSelections
 o getVisibleIndex
 public int getVisibleIndex()
Gets the row of the item that was last made visible by the method makeVisible.

 o makeVisible
 public void makeVisible(int row)
Forces the item at the specified row to be visible.

Parameters:
row - the position of the item
See Also:
getVisibleIndex
 o getRowHeight
 public int getRowHeight()
Gets the height of each row (pixels).

See Also:
setRowHeight
 o setRowHeight
 public void setRowHeight(int h)
Sets the height of each row (pixels).

HTML param name/value: "RowHeight"/an int, "VARIABLE", or "FONT_HEIGHT"

Parameters:
h - any int, or one of the following:

If set to BWTEnum.VARIABLE, the height will be calculated individually for each row.

If set to BWTEnum.FONT_HEIGHT (default), the height will be set to the height of the current font.

 o getSpacing
 public int getSpacing()
Gets the spacing between items.

See Also:
setSpacing
 o setSpacing
 public void setSpacing(int v)
Sets the spacing between items (default: 0). This value increases the HighlightThickness value.

HTML param name/value: "Spacing"/int

See Also:
setHighlightThickness
 o paintRow
 public void paintRow(int row)
Draws a row.

 o getUserDataList
 public Object[] getUserDataList()
Gets the UserDataList value.

See Also:
setUserDataList
 o setUserDataList
 public void setUserDataList(Object v[])
Sets an application-defined list of objects that are maintained for each item.


All Packages  Class Hierarchy  This Package  Previous  Next  Index