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
-
actionListeners
- List of action listeners
-
itemListeners
- List of JCItemEvent/JCListEvent listeners
-
scrolled_window
- Parent window.
-
JCListComponent()
- Creates an empty 4-row list.
-
JCListComponent(int, boolean)
- Creates a list with the specified number of visible lines.
-
JCListComponent(JCVector)
- Creates a 4-row list with the specified items.
-
JCListComponent(JCVector, Applet, String)
- Creates a 4-row list which reads parameters from the applet's HTML file.
-
addActionListener(JCActionListener)
- Adds the specified action listener to receive action events
from this list.
-
addItem(Object)
- Adds an 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.
-
addNotify()
- Calculate the item sizes.
-
allowsMultipleSelections()
- Returns true if this list allows multiple selections.
-
calcRowWidth(int)
- Calculates the width of the row.
-
calcSize(boolean)
- Calculates the list's internal sizes.
-
calcSize(int, boolean)
- Recalculates the list's internal sizes based on the row.
-
calcWidestRow()
- Calculates the widest row.
-
clear()
- Clears all items in the list.
-
countItems()
- Gets the number of items in the list.
-
deleteItem(int)
- Delete an item from the list.
-
deleteItems(int, int)
- Deletes multiple items from the list.
-
deselect(int)
- Deselects the item at the specified row, and posts an JCItemEvent.
-
deselectAll()
- Deselects all items.
-
doubleClickAction(Event, int)
- Called when the user double-clicks an item.
-
draw(Graphics, Object, int, Rectangle)
- Draws the value as a String, JCString or Image.
-
drawHighlight(boolean)
- Draws or clears the highlight rectangle (called by gotFocus).
-
drawHighlight(Graphics, int, boolean)
- Draws or clears the highlight rectangle around the row.
-
drawHighlight(int, boolean)
- Draws or clears the highlight rectangle around the row.
-
eventToRow(Event, boolean)
- Gets the row specified by the event, or BWTEnum.NOTFOUND.
-
find(Object)
- Finds the first row matching the specified item, or BWTEnum.NOTFOUND.
-
findItem(char)
- Finds the first item which starts with the specified character, or
BWTEnum.NOTFOUND if none could be found.
-
getAllowMultipleSelections()
- Returns true if this list allows multiple selections.
-
getAutoSelect()
- Gets the AutoSelect value.
-
getBatched()
- Gets the Batched value.
-
getBounds(int, boolean)
- Gets the bounding rectangle of a row, or null if the row is invalid.
-
getDoubleBufferGraphics()
- Creates a double-buffer image,
for subsequent retrieval via getDoubleBufferImage
-
getDoubleBufferImage()
- Returns the double-buffer image previously created in a call to
getDoubleBufferGraphics.
-
getHorizOrigin()
- Gets the horizontal origin.
-
getItem(int)
- Returns the item at the specified row.
-
getItems()
- Gets the list's values.
-
getItemsStrings()
- Gets the list's values as a list of Strings.
-
getParameters()
- Reads the parameter values from the HTML page using the component's applet.
-
getRowHeight()
- Gets the RowHeight value.
-
getRowHeight(int)
- Gets the height of the row calculated previously.
-
getRowPosition(int)
- Gets the position of the row calculated previously.
-
getRows()
- Returns the number of visible lines.
-
getSelectedBackground()
- Gets the list's SelectedBackground value.
-
getSelectedForeground()
- Gets the list's SelectedForeground value.
-
getSelectedIndex()
- Gets the first selected row, or BWTEnum.NOTFOUND if no item is selected.
-
getSelectedIndexes()
- Returns a list of the selected rows, or null if no items are 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.
-
getVertOrigin()
- Gets the vertical origin.
-
getVisibleIndex()
- Gets the index of the item that was last made visible by makeVisible().
-
getVisibleRange(Insets)
- Returns the top and bottom-most visible rows.
-
getVisibleRows()
- Returns the number of visible lines.
-
invalidate()
-
Invalidates the component.
-
isSelected(int)
- Returns true if the item at the specified row has been selected.
-
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.
-
makeVisible(int)
- Forces the item at the specified row to be visible.
-
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.
-
mouseDrag(Event, int, int)
- Extends the selection to a new row if AllowMultipleSelections is true.
-
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.
-
paintComponent(Graphics)
- Draws items
-
paintRow(int)
- Draws a row.
-
paintRow(int, Graphics)
- Draws a row.
-
preferredHeight()
- Returns the visible height, if it has been set, or the sum of all item heights.
-
preferredWidth()
- Returns the width of the widest item.
-
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.
-
repaint()
- Repaints the component if Batched is false.
-
replaceItem(Object, int)
- Replaces the item at the specified row.
-
select(int)
- Selects the item at the specified row, and posts a JCListEvent.
-
select(int, boolean)
- Selects the item at the specified row, and posts a JCListEvent.
-
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.
-
setDoubleBuffer(boolean)
- Controls whether double-buffering is used when displaying
and updating the component (default: true).
HTML param name/value: "DoubleBuffer"/boolean
-
setFont(Font)
- Sets the font of the component.
-
setHorizOrigin(int)
- Sets the horizontal origin prior to scrolling.
-
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 an array of Strings.
-
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.
-
setVertOrigin(int)
- Sets the vertical origin prior to scrolling.
-
setVisibleRows(int)
- Sets the number of visible rows (default: 4).
-
updateSelectedList()
- Updates the selected item list after an item has changed.
-
updateUserdataList()
- Updates the userdata list after an item has changed.
actionListeners
protected JCVector actionListeners
- List of action listeners
itemListeners
protected JCVector itemListeners
- List of JCItemEvent/JCListEvent listeners
scrolled_window
protected JCScrolledWindow scrolled_window
- Parent window.
JCListComponent
public JCListComponent()
- Creates an empty 4-row list.
No parameters are read from an HTML file.
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
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
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.
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
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
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
setDoubleBuffer
public void setDoubleBuffer(boolean v)
- Controls whether double-buffering is used when displaying
and updating the component (default: true).
HTML param name/value: "DoubleBuffer"/boolean
- Overrides:
- setDoubleBuffer in class JCComponent
invalidate
public void invalidate()
- Invalidates the component.
- Overrides:
- invalidate in class Component
getDoubleBufferImage
public Image getDoubleBufferImage()
- Returns the double-buffer image previously created in a call to
getDoubleBufferGraphics.
- Overrides:
- getDoubleBufferImage in class JCComponent
getDoubleBufferGraphics
public synchronized Graphics getDoubleBufferGraphics()
- Creates a double-buffer image,
for subsequent retrieval via getDoubleBufferImage
- Overrides:
- getDoubleBufferGraphics in class JCComponent
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.
getItems
public JCVector getItems()
- Gets the list's values.
- See Also:
- setItems
getItem
public Object getItem(int row)
- Returns the item at the specified row.
- See Also:
- setItems
setItems
public void setItems(String items[])
- Sets the list's values as an array of Strings.
getItemsStrings
public synchronized String[] getItemsStrings()
- Gets the list's values as a list of Strings.
- See Also:
- setItems
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
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.
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
countItems
public int countItems()
- Gets the number of items in the list.
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
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).
replaceItem
public synchronized void replaceItem(Object item,
int row)
- Replaces the item at the specified row.
clear
public synchronized void clear()
- Clears all items in the list.
- See Also:
- deleteItems
deleteItems
public synchronized void deleteItems(int start_row,
int end_row)
- Deletes multiple items from the list.
#see clear
deleteItem
public synchronized void deleteItem(int row)
- Delete an item from the list.
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
getSelectedIndex
public synchronized int getSelectedIndex()
- Gets the first selected row, or BWTEnum.NOTFOUND if no item is selected.
- See Also:
- select, deselect, isSelected
getTopRow
public int getTopRow()
- Gets the current top-most visible row.
- See Also:
- setTopRow
setTopRow
public void setTopRow(int row)
- Sets the top-most visible row.
- See Also:
- makeVisible
makeVisible
public void makeVisible(int row)
- Forces the item at the specified row to be visible.
getVisibleIndex
public int getVisibleIndex()
- Gets the index of the item that was last made visible by makeVisible().
- See Also:
- makeVisible
getSelectedItem
public synchronized 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
getSelectedIndexes
public synchronized int[] getSelectedIndexes()
- Returns a list of the selected rows, or null if no items are selected.
- See Also:
- select, deselect, isSelected
deselect
public synchronized void deselect(int row)
- Deselects the item at the specified row, and posts an JCItemEvent.
- See Also:
- select, getSelectedIndex, isSelected, addItemListener
deselectAll
public synchronized void deselectAll()
- Deselects all items. No events are posted
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
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, 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
find
public int find(Object item)
- Finds the first row matching the specified item, or BWTEnum.NOTFOUND.
isSelected
public synchronized boolean isSelected(int row)
- Returns true if the item at the specified row has been selected.
- See Also:
- select, deselect
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
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
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
getRowHeight
protected int getRowHeight(int row)
- Gets the height of the row calculated previously.
calcRowWidth
protected int calcRowWidth(int row)
- Calculates the width of the row.
getRowPosition
protected int getRowPosition(int row)
- Gets the position of the row calculated previously.
getRowHeight
public int getRowHeight()
- Gets the RowHeight value.
- 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.
- Throws: IllegalArgumentException
- If an invalid value is set
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
getRows
public int getRows()
- Returns the number of visible lines.
- See Also:
- setVisibleRows
getVisibleRows
public int getVisibleRows()
- Returns the number of visible lines.
- See Also:
- setVisibleRows
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
getVisibleRange
public void getVisibleRange(Insets range)
- Returns the top and bottom-most visible rows.
- Parameters:
- range - returned
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
findItem
public int findItem(char c)
- Finds the first item which starts with the specified character, or
BWTEnum.NOTFOUND if none could be found.
calcSize
protected void calcSize(boolean update_parent)
- Calculates the list's internal sizes.
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
updateSelectedList
protected void updateSelectedList()
- Updates the selected item list after an item has changed.
updateUserdataList
protected void updateUserdataList()
- Updates the userdata list after an item has changed.
calcWidestRow
protected int calcWidestRow()
- Calculates the widest row.
repaint
public synchronized void repaint()
- Repaints the component if Batched is false.
- Overrides:
- repaint in class JCComponent
- See Also:
- setBatched
addNotify
public void addNotify()
- Calculate the item sizes.
- Overrides:
- addNotify in class JCComponent
preferredWidth
protected int preferredWidth()
- Returns the width of the widest item.
- Overrides:
- preferredWidth in class JCComponent
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
paintRow
public void paintRow(int row)
- Draws a row.
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
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
drawHighlight
protected void drawHighlight(int row,
boolean on)
- Draws or clears the highlight rectangle around the row.
drawHighlight
protected void drawHighlight(Graphics gc,
int row,
boolean on)
- Draws or clears the highlight rectangle around the row.
paintRow
protected synchronized void paintRow(int row,
Graphics gc)
- Draws a row.
paintComponent
protected synchronized void paintComponent(Graphics gc)
- Draws items
- Overrides:
- paintComponent in class JCComponent
doubleClickAction
protected boolean doubleClickAction(Event ev,
int row)
- Called when the user double-clicks an item. An JCActionEvent is posted.
- See Also:
- addActionListener
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
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
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
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
getHorizOrigin
public int getHorizOrigin()
- Gets the horizontal origin.
setHorizOrigin
public void setHorizOrigin(int v)
- Sets the horizontal origin prior to scrolling.
getVertOrigin
public int getVertOrigin()
- Gets the vertical origin.
setVertOrigin
public void setVertOrigin(int value)
- Sets the vertical origin prior to scrolling.
All Packages Class Hierarchy This Package Previous Next Index