    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

- If an item is clicked (or the space key is hit) with no other key pressed, the item is selected if it was previously unselected, or unselected if it was previously selected. The previously selected items are unselected.
- If an item is clicked (or the space key is hit) with the SHIFT key down, the current selection is extended from the current anchor to the item if AllowMultipleSelections is true. If the anchor item is selected, the selection will be selected; if the anchor item is unselected, the selection will be unselected.
- If an item is clicked (or the space key is hit) with the CONTROL key down, the current selection is toggled if AllowMultipleSelections is true, and the item becomes the new anchor. If the mouse is dragged across items, they are selected if AllowMultipleSelections is true.
- Hitting the up or down arrow keys moves the focus item, which is shown as a 2-pixel rectangle drawn around the item. The list will scroll if necessary to display the focus item.
- Typing a character will cause the first item which starts with the character to be made visible and selected. If no item can be found, no action is take

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

##

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

##

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

  HTML param name/value: "AutoSelect"/boolean

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

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

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

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

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

  HTML param name/value: "SelectedBackground"/color

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

  HTML param name/value: "SelectedForeground"/color

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

##

JCList

      public JCList()

  Creates an empty 4-row list. No parameters are read from an HTML file.

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

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.

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

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

##

getList

      public JCListComponent getList()

  Gets the internal list.

setList

      public void setList(JCListComponent list)

  Replaces the current internal list.

preferredWidth

      protected int preferredWidth()

  Gets the subclass' preferred width (default: 100).

  Overrides:
    preferredWidth in class JCScrolledWindow

getViewportHeight

      protected int getViewportHeight()

  Sets the work area height to be the list's virtual height.

  Overrides:
    getViewportHeight in class JCScrolledWindow

scrollVertical

      protected void scrollVertical(JCScrollableInterface scrollable,
                                    JCAdjustmentEvent ev,
                                    int value)

  Scrolls the list vertically.

  Overrides:
    scrollVertical in class JCScrolledWindow

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

removeItemListener

      public void removeItemListener(JCItemListener l)

  Removes the specified item listener so it no longer receives item events from this list.

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

removeActionListener

      public void removeActionListener(JCActionListener l)

  Removes the specified action listener so it no longer receives action events from this list.

  See Also:
    addActionListener

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

getItems

      public synchronized JCVector getItems()

  Gets the list's values.

  See Also:
    setItems

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

setItems

      public synchronized void setItems(String items[])

  Sets the list's values as a list of Strings.

getItemsStrings

      public synchronized String[] getItemsStrings()

  Gets the list's values as a list of Strings.

  See Also:
    setItems

setItemsStrings

      public synchronized void setItemsStrings(String items[])

  Sets the list's values as a list of Strings.

countItems

      public int countItems()

  Returns the number of items in the list.

  See Also:
    getItem

getItem

      public Object getItem(int row)

  Gets the item associated with the specified index.

  Parameters:
    row - the position of the item
  See Also:
    countItems

addItem

      public synchronized void addItem(Object item)

  Adds the specified item to the end of the list.

  Parameters:
    item - the item to be added

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

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

getBatched

      public boolean getBatched()

  Gets the Batched value.

  See Also:
    setBatched

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.

clear

      public synchronized void clear()

  Clears the list.

  See Also:
    deleteItem, deleteItems

deleteItem

      public synchronized void deleteItem(int row)

  Deletes an item from the list.

deleteItems

      public synchronized void deleteItems(int start,
                                           int end)

  Delete multiple items from the list.

find

      public int find(Object item)

  Finds the first row matching the specified item, or BWTEnum.NOTFOUND.

getSelectedIndex

      public int getSelectedIndex()

  Gets the selected item on the list or BWTEnum.NOTFOUND if no item is selected.

  See Also:
    select, deselect, isSelected

getSelectedIndexes

      public int[] getSelectedIndexes()

  Returns the selected indexes on the list, or null if no item is selected.

  See Also:
    select, deselect, isSelected

getSelectedItem

      public Object getSelectedItem()

  Returns the selected item on the list, or null if no item is selected.

  See Also:
    select, deselect, isSelected

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

getAutoSelect

      public boolean getAutoSelect()

  Gets the AutoSelect value.

  See Also:
    setAutoSelect

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

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

select

      public synchronized void select(Object item)

  Selects the specified item.

  See Also:
    getSelectedItem, getSelectedIndex

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

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

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

deselectAll

      public synchronized void deselectAll()

  Deselects all items. No events are posted

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

getSelectedBackground

      public Color getSelectedBackground()

  Gets the list's SelectedBackground value.

  See Also:
    setSelectedBackground

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

getSelectedForeground

      public Color getSelectedForeground()

  Gets the list's SelectedForeground value.

  See Also:
    setSelectedForeground

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

getRows

      public int getRows()

  Returns the number of visible lines in this list.

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

getTopRow

      public int getTopRow()

  Gets the current top-most visible row.

  See Also:
    setTopRow

setTopRow

      public synchronized void setTopRow(int row)

  Sets the top-most visible row.

  See Also:
    makeVisible

allowsMultipleSelections

      public boolean allowsMultipleSelections()

  Returns true if this list allows multiple selections.

  See Also:
    setAllowMultipleSelections

getAllowMultipleSelections

      public boolean getAllowMultipleSelections()

  Returns true if this list allows multiple selections.

  See Also:
    setAllowMultipleSelections

setAllowMultipleSelections

      public void setAllowMultipleSelections(boolean v)

  Sets whether the list allows multiple selections. HTML param name/value: "AllowMultipleSelections"/boolean

  See Also:
    allowsMultipleSelections

getVisibleIndex

      public int getVisibleIndex()

  Gets the row of the item that was last made visible by the method makeVisible.

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

getRowHeight

      public int getRowHeight()

  Gets the height of each row (pixels).

  See Also:
    setRowHeight

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.

getSpacing

      public int getSpacing()

  Gets the spacing between items.

  See Also:
    setSpacing

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

paintRow

      public void paintRow(int row)

  Draws a row.

getUserDataList

      public Object[] getUserDataList()

  Gets the UserDataList value.

  See Also:
    setUserDataList

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