All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jclass.bwt.JCListComponent

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----jclass.bwt.JCComponent
                           |
                           +----jclass.bwt.JCListComponent

public class JCListComponent
extends JCComponent
implements JCListInterface, JCScrollableInterface, JCItemSelectable
A list of text and/or image items. To create a scrollable list, use JCList.

See Also:
JCList

Variable Index

 o actionListeners
List of action listeners
 o itemListeners
List of JCItemEvent/JCListEvent listeners
 o scrolled_window
Parent window.

Constructor Index

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

Method Index

 o addActionListener(JCActionListener)
Adds the specified action listener to receive action events from this list.
 o addItem(Object)
Adds an 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 addNotify()
Calculate the item sizes.
 o allowsMultipleSelections()
Returns true if this list allows multiple selections.
 o calcRowWidth(int)
Calculates the width of the row.
 o calcSize(boolean)
Calculates the list's internal sizes.
 o calcSize(int, boolean)
Recalculates the list's internal sizes based on the row.
 o calcWidestRow()
Calculates the widest row.
 o clear()
Clears all items in the list.
 o countItems()
Gets the number of items in the list.
 o deleteItem(int)
Delete an item from the list.
 o deleteItems(int, int)
Deletes multiple items from the list.
 o deselect(int)
Deselects the item at the specified row, and posts an JCItemEvent.
 o deselectAll()
Deselects all items.
 o doubleClickAction(Event, int)
Called when the user double-clicks an item.
 o draw(Graphics, Object, int, Rectangle)
Draws the value as a String, JCString or Image.
 o drawHighlight(boolean)
Draws or clears the highlight rectangle (called by gotFocus).
 o drawHighlight(Graphics, int, boolean)
Draws or clears the highlight rectangle around the row.
 o drawHighlight(int, boolean)
Draws or clears the highlight rectangle around the row.
 o eventToRow(Event, boolean)
Gets the row specified by the event, or BWTEnum.NOTFOUND.
 o find(Object)
Finds the first row matching the specified item, or BWTEnum.NOTFOUND.
 o findItem(char)
Finds the first item which starts with the specified character, or BWTEnum.NOTFOUND if none could be found.
 o getAllowMultipleSelections()
Returns true if this list allows multiple selections.
 o getAutoSelect()
Gets the AutoSelect value.
 o getBatched()
Gets the Batched value.
 o getBounds(int, boolean)
Gets the bounding rectangle of a row, or null if the row is invalid.
 o getDoubleBufferGraphics()
Creates a double-buffer image, for subsequent retrieval via getDoubleBufferImage
 o getDoubleBufferImage()
Returns the double-buffer image previously created in a call to getDoubleBufferGraphics.
 o getHorizOrigin()
Gets the horizontal origin.
 o getItem(int)
Returns the item at the specified row.
 o getItems()
Gets the list's values.
 o getItemsStrings()
Gets the list's values as a list of Strings.
 o getParameters()
Reads the parameter values from the HTML page using the component's applet.
 o getRowHeight()
Gets the RowHeight value.
 o getRowHeight(int)
Gets the height of the row calculated previously.
 o getRowPosition(int)
Gets the position of the row calculated previously.
 o getRows()
Returns the number of visible lines.
 o getSelectedBackground()
Gets the list's SelectedBackground value.
 o getSelectedForeground()
Gets the list's SelectedForeground value.
 o getSelectedIndex()
Gets the first selected row, or BWTEnum.NOTFOUND if no item is selected.
 o getSelectedIndexes()
Returns a list of the selected rows, or null if no items are 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 getVertOrigin()
Gets the vertical origin.
 o getVisibleIndex()
Gets the index of the item that was last made visible by makeVisible().
 o getVisibleRange(Insets)
Returns the top and bottom-most visible rows.
 o getVisibleRows()
Returns the number of visible lines.
 o invalidate()
Invalidates the component.
 o isSelected(int)
Returns true if the item at the specified row has been selected.
 o keyDown(Event, int)
Moves selection up or down if arrow key hit; posts an JCActionEvent if ENTER is hit; otherwise selects item which starts with the character.
 o makeVisible(int)
Forces the item at the specified row to be visible.
 o mouseDown(Event, int, int)
If the event's clickCount is greater than 1 calls doubleClickAction.

If the SHIFT key is pressed, extends the current selection.

If the CONTROL key is pressed, toggles the current selection.

Otherwise the click point is toggled.

 o mouseDrag(Event, int, int)
Extends the selection to a new row if AllowMultipleSelections is true.
 o mouseUp(Event, int, int)
If the event's clickCount is greater than 1, no action is taken.

If the SHIFT key is pressed, extension of the current selection is ended.

If the CONTROL key is pressed, toggling of the current selection is ended.

Otherwise the click point is toggled.

 o paintComponent(Graphics)
Draws items
 o paintRow(int)
Draws a row.
 o paintRow(int, Graphics)
Draws a row.
 o preferredHeight()
Returns the visible height, if it has been set, or the sum of all item heights.
 o preferredWidth()
Returns the width of the widest item.
 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 removeItemListener(JCItemListener)
Removes the specified item listener so it no longer receives item events from this list.
 o repaint()
Repaints the component if Batched is false.
 o replaceItem(Object, int)
Replaces the item at the specified row.
 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, and posts a JCListEvent.
 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 setDoubleBuffer(boolean)
Controls whether double-buffering is used when displaying and updating the component.

HTML param name/value: "DoubleBuffer"/boolean

 o setFont(Font)
Sets the font of the component.
 o setHorizOrigin(int)
Sets the horizontal origin prior to scrolling.
 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 an array of Strings.
 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 setVertOrigin(int)
Sets the vertical origin prior to scrolling.
 o setVisibleRows(int)
Sets the number of visible rows (default: 4).
 o updateSelectedList()
Updates the selected item list after an item has changed.
 o updateUserdataList()
Updates the userdata list after an item has changed.

Variables

 o actionListeners
  protected JCVector actionListeners
List of action listeners

 o itemListeners
  protected JCVector itemListeners
List of JCItemEvent/JCListEvent listeners

 o scrolled_window
  protected JCScrolledWindow scrolled_window
Parent window.

Constructors

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

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

See Also:
setItems
 o JCListComponent
  public JCListComponent(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 This 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 JCListComponent
  public JCListComponent(int rows,
                         boolean multipleSelections)
Creates a list with the specified number of visible lines.

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 getParameters
  protected void getParameters()
Reads the parameter values from the HTML page using the component's applet. The values will override those previously set.

Overrides:
getParameters in class JCComponent
 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 setFont
  public synchronized void setFont(Font f)
Sets the font of the component. HTML param name/value: "Font"/font

Overrides:
setFont in class JCComponent
See Also:
toFont
 o setDoubleBuffer
  public void setDoubleBuffer(boolean v)
Controls whether double-buffering is used when displaying and updating the component.

HTML param name/value: "DoubleBuffer"/boolean

Overrides:
setDoubleBuffer in class JCComponent
 o invalidate
  public void invalidate()
Invalidates the component.

Overrides:
invalidate in class Component
 o getDoubleBufferImage
  public Image getDoubleBufferImage()
Returns the double-buffer image previously created in a call to getDoubleBufferGraphics.

Overrides:
getDoubleBufferImage in class JCComponent
 o getDoubleBufferGraphics
  public synchronized Graphics getDoubleBufferGraphics()
Creates a double-buffer image, for subsequent retrieval via getDoubleBufferImage

Overrides:
getDoubleBufferGraphics in class JCComponent
 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.

 o getItems
  public JCVector getItems()
Gets the list's values.

See Also:
setItems
 o getItem
  public Object getItem(int row)
Returns the item at the specified row.

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

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

See Also:
setItems
 o setItems
  public 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 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 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 countItems
  public int countItems()
Gets the number of items in the list.

 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 addItem
  public synchronized void addItem(Object item)
Adds an item to the end of 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).
 o replaceItem
  public synchronized void replaceItem(Object item,
                                       int row)
Replaces the item at the specified row.

 o clear
  public synchronized void clear()
Clears all items in the list.

See Also:
deleteItems
 o deleteItems
  public synchronized void deleteItems(int start_row,
                                       int end_row)
Deletes multiple items from the list. #see clear

 o deleteItem
  public synchronized void deleteItem(int row)
Delete an item from the list.

 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
 o getSelectedIndex
  public synchronized int getSelectedIndex()
Gets the first selected row, or BWTEnum.NOTFOUND if no item is selected.

See Also:
select, deselect, isSelected
 o getTopRow
  public int getTopRow()
Gets the current top-most visible row.

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

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

 o getVisibleIndex
  public int getVisibleIndex()
Gets the index of the item that was last made visible by makeVisible().

See Also:
makeVisible
 o getSelectedItem
  public synchronized 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 getSelectedIndexes
  public synchronized int[] getSelectedIndexes()
Returns a list of the selected rows, or null if no items are selected.

See Also:
select, deselect, isSelected
 o deselect
  public synchronized void deselect(int row)
Deselects the item at the specified row, and posts an JCItemEvent.

See Also:
select, getSelectedIndex, isSelected, addItemListener
 o deselectAll
  public synchronized void deselectAll()
Deselects all items. No events are posted

 o select
  public synchronized void select(int row)
Selects the item at the specified row, and posts a JCListEvent. If allowsMultipleSelections is false, any previously selected rows are deselected.

See Also:
setAllowMultipleSelections, 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, and posts a JCListEvent. If allowsMultipleSelections is false, any previously selected rows are deselected.

Parameters:
notify - if true, a JCListEvent is posted.
See Also:
setAllowMultipleSelections, addItemListener
 o find
  public int find(Object item)
Finds the first row matching the specified item, or BWTEnum.NOTFOUND.

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

See Also:
select, deselect
 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 getBounds
  public Rectangle getBounds(int row,
                             boolean adjust)
Gets the bounding rectangle of a row, or null if the row is invalid.

Parameters:
adjust - if true, the co-ordinates are adjusted by the amount that the list has been scrolled
See Also:
makeVisible
 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 getRowHeight
  protected int getRowHeight(int row)
Gets the height of the row calculated previously.

 o calcRowWidth
  protected int calcRowWidth(int row)
Calculates the width of the row.

 o getRowPosition
  protected int getRowPosition(int row)
Gets the position of the row calculated previously.

 o getRowHeight
  public int getRowHeight()
Gets the RowHeight value.

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.

Throws: IllegalArgumentException
If an invalid value is set
 o eventToRow
  public int eventToRow(Event ev,
                        boolean visible)
Gets the row specified by the event, or BWTEnum.NOTFOUND.

Parameters:
visible - if true, the row must be visible
 o getRows
  public int getRows()
Returns the number of visible lines.

See Also:
setVisibleRows
 o getVisibleRows
  public int getVisibleRows()
Returns the number of visible lines.

See Also:
setVisibleRows
 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.

See Also:
setItems
 o getVisibleRange
  public void getVisibleRange(Insets range)
Returns the top and bottom-most visible rows.

Parameters:
range - returned
 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 findItem
  public int findItem(char c)
Finds the first item which starts with the specified character, or BWTEnum.NOTFOUND if none could be found.

 o calcSize
  protected void calcSize(boolean update_parent)
Calculates the list's internal sizes.

 o calcSize
  protected synchronized void calcSize(int row,
                                       boolean new_row)
Recalculates the list's internal sizes based on the row.

Parameters:
new_row - whether this is a new item
 o updateSelectedList
  protected void updateSelectedList()
Updates the selected item list after an item has changed.

 o updateUserdataList
  protected void updateUserdataList()
Updates the userdata list after an item has changed.

 o calcWidestRow
  protected int calcWidestRow()
Calculates the widest row.

 o repaint
  public synchronized void repaint()
Repaints the component if Batched is false.

Overrides:
repaint in class JCComponent
See Also:
setBatched
 o addNotify
  public void addNotify()
Calculate the item sizes.

Overrides:
addNotify in class JCComponent
 o preferredWidth
  protected int preferredWidth()
Returns the width of the widest item.

Overrides:
preferredWidth in class JCComponent
 o preferredHeight
  protected int preferredHeight()
Returns the visible height, if it has been set, or the sum of all item heights.

Overrides:
preferredHeight in class JCComponent
 o paintRow
  public void paintRow(int row)
Draws a row.

 o draw
  protected void draw(Graphics gc,
                      Object value,
                      int alignment,
                      Rectangle draw_rect)
Draws the value as a String, JCString or Image.

Parameters:
alignment - one of: BWTEnum.TOPLEFT, TOPCENTER, TOPRIGHT, MIDDLELEFT, MIDDLECENTER, MIDDLERIGHT, BOTTOMLEFT, BOTTOMCENTER and BOTTOMRIGHT
draw_rect - rectangle within which to draw the value
 o drawHighlight
  protected void drawHighlight(boolean on)
Draws or clears the highlight rectangle (called by gotFocus).

Parameters:
on - if true, draws the highlight rectangle; otherwise clears the rect
Overrides:
drawHighlight in class JCComponent
 o drawHighlight
  protected void drawHighlight(int row,
                               boolean on)
Draws or clears the highlight rectangle around the row.

 o drawHighlight
  protected void drawHighlight(Graphics gc,
                               int row,
                               boolean on)
Draws or clears the highlight rectangle around the row.

 o paintRow
  protected synchronized void paintRow(int row,
                                       Graphics gc)
Draws a row.

 o paintComponent
  protected synchronized void paintComponent(Graphics gc)
Draws items

Overrides:
paintComponent in class JCComponent
 o doubleClickAction
  protected boolean doubleClickAction(Event ev,
                                      int row)
Called when the user double-clicks an item. An JCActionEvent is posted.

See Also:
addActionListener
 o mouseDrag
  public boolean mouseDrag(Event ev,
                           int x,
                           int y)
Extends the selection to a new row if AllowMultipleSelections is true.

Overrides:
mouseDrag in class Component
See Also:
setAllowMultipleSelections
 o mouseDown
  public boolean mouseDown(Event ev,
                           int x,
                           int y)
If the event's clickCount is greater than 1 calls doubleClickAction.

If the SHIFT key is pressed, extends the current selection.

If the CONTROL key is pressed, toggles the current selection.

Otherwise the click point is toggled.

Overrides:
mouseDown in class JCComponent
 o mouseUp
  public boolean mouseUp(Event ev,
                         int x,
                         int y)
If the event's clickCount is greater than 1, no action is taken.

If the SHIFT key is pressed, extension of the current selection is ended.

If the CONTROL key is pressed, toggling of the current selection is ended.

Otherwise the click point is toggled.

Overrides:
mouseUp in class Component
 o keyDown
  public boolean keyDown(Event ev,
                         int key)
Moves selection up or down if arrow key hit; posts an JCActionEvent if ENTER is hit; otherwise selects item which starts with the character.

Overrides:
keyDown in class Component
 o getHorizOrigin
  public int getHorizOrigin()
Gets the horizontal origin.

 o setHorizOrigin
  public void setHorizOrigin(int v)
Sets the horizontal origin prior to scrolling.

 o getVertOrigin
  public int getVertOrigin()
Gets the vertical origin.

 o setVertOrigin
  public void setVertOrigin(int value)
Sets the vertical origin prior to scrolling.


All Packages  Class Hierarchy  This Package  Previous  Next  Index