All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class COM.taligent.widget.MultiColumnListbox

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----COM.taligent.widget.MultiColumnListbox

public class MultiColumnListbox
extends Panel
implements WindowListener, ActionListener, ItemSelectable, FocusListener, KeyListener, MouseListener, AdjustmentListener, CaptionBarListener
A simple multi-column listbox. To use the listbox, create columns and then add rows of data. By default, the listbox contains text string values, but you can implement the Paintable interface and insert special "painted" objects. You can also insert any AWT Component or custom Component.

Each column has the ability to be resized and sorted using custom sorting algorithms. To create a sorting function for a column, extend COM.taligent.util.Sorter to provide the sorting behavior you want and implement COM.taligent.util.Comparator to provide a sort comparison.

The listbox passes selection events to all registered ListboxListener objects. Column selection/resizing events are passed to all registered CaptionBarListener objects.

See Also:
ListboxColumn, Paintable, Sorter

Variable Index

 o background
 o bar
 o columns
 o DEFAULT_BACKGROUND_COLOR
Default background color (Color.lightGray).
 o DEFAULT_CAPTIONBAR_HEIGHT
Default caption bar height.
 o DEFAULT_FOREGROUND_COLOR
Default foreground color (Color.black).
 o DEFAULT_KEY
Default row key value (null).
 o DEFAULT_ROW_HEIGHT
Default row height (20).
 o DEFAULT_SELECTION_BACKGROUND
Default selected background color (Color.gray).
 o DEFAULT_SELECTION_FOREGROUND
Default selected foreground color (Color.black).
 o DEFAULT_SEPARATOR_COLOR
Default separator color (Color.black).
 o hsep
 o lastselected
 o rowheight
 o selected
 o sepcolor
 o serialVersionUID
Standard *** private final static boolean REGISTERED = false; /
 o vsep

Constructor Index

 o MultiColumnListbox()
Constructor.

Method Index

 o actionPerformed(ActionEvent)
 o addAdjustmentListener(AdjustmentListener, int)
Adds a scrollbar adjustment listener.
 o addCaptionBarListener(CaptionBarListener)
Adds a caption bar event listener.
 o addColumn(String)
Adds a column to the listbox.
 o addColumns(String[])
Adds a series of columns to the listbox.
 o addItemListener(ItemListener)
Adds an item listener.
 o addListboxListener(ListboxListener)
Adds a listbox event listener.
 o addRow(Object[])
Add a new row to the multi-column listbox with the default key value.
 o addRow(Object[], Object)
Add a new row to the multi-column listbox with a given key.
 o addRows(Object[][])
Adds a series of rows with the default key value.
 o addRows(Object[][], Object[])
Adds a series of rows with the specified key values.
 o adjustmentValueChanged(AdjustmentEvent)
A scrollbar was adjusted.
 o allowsMultipleSelections()
Returns whether multiple selections are allowed. Deprecated.
 o autoSizeColumn(int)
Resizes the specified column to fit the widest element currently in the column.
 o captionResized(CaptionBarEvent)
A caption was resized.
 o captionSelected(CaptionBarEvent)
A caption was selected.
 o clear()
Removes all the rows from the listbox. Deprecated.
 o countColumns()
Returns the number of columns in the listbox. Deprecated.
 o countRows()
Returns the number of rows in the listbox. Deprecated.
 o deleteColumn(int)
Removes a column from the listbox. Deprecated.
 o deleteRow(int)
Removes a row from the listbox. Deprecated.
 o deselectAllRows()
Deselects all of the rows.
 o deselectRow(int)
Deselects a row.
 o deselectRowByKey(Object)
Deselects the first row with the given key.
 o focusGained(FocusEvent)
When focus is gained, redraws the listbox indicating the focus.
 o focusLost(FocusEvent)
When focus is lost, redraw the list without focus indicator.
 o getBackgroundImage()
Returns the current background image or null if none is set.
 o getCaptionBarBackground()
Returns the current background color of the caption bar.
 o getCaptionBarBackgroundImage()
Returns the current background image of the caption bar or null if none is set.
 o getCaptionBarForeground()
Returns the current foreground color of the caption bar.
 o getCaptionBarHeight()
Returns the current caption bar height.
 o getColumn(int)
Returns the array of values in the column, or null if column specified is invalid.
 o getColumnCount()
Returns the number of columns in the listbox.
 o getColumnInfo(int)
Returns a reference to specified column or null if no such column index exists.
 o getContinuousDrag()
Returns whether the columns are resized as the caption is resized or only at the end of the drag.
 o getIndexByKey(Object)
Returns the index of the first row that has the specified key or -1 if no row has that key.
 o getKeys()
Returns the array of key values, or null if there are no columns or rows in the list.
 o getMinimumSize()
Returns the minimum size of this component.
 o getMultipleSelections()
Returns whether multiple selections are allowed.
 o getName()
Returns a unique name for this listbox.
 o getPreferredSize()
Returns the preferred size of the listbox which is just the minimum size.
 o getRow(int)
Returns the array of values in the row, or null if row specified is invalid.
 o getRowByKey(Object)
Returns an array of row values with the specified key or null if no row has the specified key.
 o getRowCount()
Returns the number of rows in the listbox.
 o getRowHeight()
Returns the current height of the listbox rows.
 o getRowKey(int)
Returns the key value for the specified row.
 o getSelectedColumnIndex()
Returns the index of the selected column.
 o getSelectedIndex()
Returns the index of the first selected row or -1 if no row is selected.
 o getSelectedIndexes()
Returns an array of indexes of the selected rows.
 o getSelectedObjects()
Returns an array of selected row arrays.
 o getSelectedRow()
Returns the first selected row.
 o getSelectedRows()
Returns all of the selected rowsas an array of rows.
 o getSelectionBackground()
Gets the current background color for all selected rows.
 o getSelectionForeground()
Gets the foreground color for all selected rows.
 o getSeparatorColor()
Returns the current color of the horizontal and vertical separators.
 o getUpdate()
Returns whether update are turned on or off.
 o hideBorder()
Hides the border around the listbox. Deprecated.
 o hideHorizontalSeparator()
Hides a horizontal separator line between each row. Deprecated.
 o hideVerticalSeparator()
Hides a vertical separator line between each column. Deprecated.
 o horizontalScrollAdjustment()
Readjusts caption bar and list area.
 o horizontalSeparatorShown()
Returns whether horizontal separator lines are shown between each listbox row. Deprecated.
 o insertRow(Object[], int)
Inserts a row of data into the listbox with the default key value.
 o insertRow(Object[], Object, int)
Inserts a row of data into the listbox.
 o insertRows(Object[][], int)
Inserts the given rows at the specified index with the default key value.
 o insertRows(Object[][], Object[], int)
Inserts the given rows at the specified index and the key values.
 o isCaptionBarVisible()
Returns whether or not the caption bar is being shown.
 o isFocusTraversable()
The listbox is always traversable.
 o isHorizontalScrollbarVisible()
Returns whether the horizontal scrollbar is shown.
 o isHorizontalSeparatorVisible()
Returns whether horizontal separator lines are shown between each listbox row.
 o isVerticalScrollbarVisible()
Returns whether the vertical scrollbar is shown.
 o isVerticalSeparatorVisible()
Returns whether the vertical separators are being shown.
 o keyPressed(KeyEvent)
A key was pressed.
 o keyReleased(KeyEvent)
A key was released.
 o keyTyped(KeyEvent)
A key was typed.
 o makeRowVisible(int)
Makes the specified row index visible in the listbox.
 o mouseClicked(MouseEvent)
A mouse button was clicked.
 o mouseEntered(MouseEvent)
The mouse cursor entered the component.
 o mouseExited(MouseEvent)
The mouse cursor exited the component.
 o mousePressed(MouseEvent)
A mouse button was pressed.
 o mouseReleased(MouseEvent)
A mouse button was released.
 o paint(Graphics)
Paints the listbox.
 o paintHook(String, int, int)
This hook allows descendant classes to change the text of a specific entry *before* it's printed but without changing the data stored in the element.
 o removeAdjustmentListener(AdjustmentListener, int)
Removes a scrollbar adjustment listener.
 o removeAllColumns()
Removes all of the columns from the listbox.
 o removeAllRows()
Removes all the rows from the listbox.
 o removeCaptionBarListener(CaptionBarListener)
Removes a caption bar event listener.
 o removeColumn(int)
Removes a column from the listbox.
 o removeItemListener(ItemListener)
Removes an item listener
 o removeListboxListener(ListboxListener)
Removes a listbox event listener.
 o removeRow(int)
Removes a row from the listbox.
 o removeRows(int, int)
Removes a series of rows.
 o repaint()
Repaint caption bar and list area.
 o replaceColumn(Object[], int)
Replaces the elements in the given column with the array of objects specified.
 o replaceRow(Object[], int)
Replaces all elements of the given row with the text strings specified.
 o resetHorizontalScrollbar()
Resets the horizontal scrollbar -- internal to listbox.
 o resetVerticalScrollbar()
Resets the vertical scrollbar -- internal to listbox.
 o selectAllRows()
Selects all of the rows.
 o selectColumn(int)
Selects the specified column.
 o selectRow(int)
Selects a row.
 o selectRowByKey(Object)
Selects the first row with the given key.
 o setBackgroundImage(Image)
Sets the background image for drawing.
 o setBounds(int, int, int, int)
Reshapes the listbox and all the internal components.
 o setCaptionBarBackground(Color)
Sets the background color of the caption bar.
 o setCaptionBarBackgroundImage(Image)
Sets the background image of the caption bar.
 o setCaptionBarForeground(Color)
Sets the foreground color of the caption bar.
 o setCaptionBarHeight(int)
Sets the size of the caption bar to the specified height.
 o setCaptionBarVisible(boolean)
Shows or hides the caption bar.
 o setContinuousDrag(boolean)
Sets whether the columns are resized as the caption is resized or only at the end of the drag.
 o setHorizontalScrollbarVisible(boolean)
Shows or hides the horizontal scrollbar.
 o setHorizontalSeparatorVisible(boolean)
Shows or hides a horizontal separator line between each row.
 o setLayout(LayoutManager)
Cannot reset the layout manager of this widget.
 o setMultipleSelections(boolean)
Sets whether multiple selections are allowed in the listbox.
 o setName(String)
Sets the name of the component.
 o setRowHeight(int)
Sets the height of the listbox rows.
 o setRowKey(Object, int)
Sets the key to the specified row.
 o setSelectionBackground(Color)
Sets the background color for all selected rows.
 o setSelectionForeground(Color)
Sets the foreground color for all selected rows.
 o setSeparatorColor(Color)
Sets the color of the horizontal and vertical separators.
 o setUpdate(boolean)
Sets whether updates occur.
 o setVerticalScrollbarVisible(boolean)
Shows or hides the vertical scrollbar.
 o setVerticalSeparatorVisible(boolean)
Show or hides a vertical separator line between each column.
 o showBorder()
Shows a border around the listbox. Deprecated.
 o showHorizontalSeparator()
Shows a horizontal separator line between each row. Deprecated.
 o showVerticalSeparator()
Shows a vertical separator line between each column. Deprecated.
 o sort()
Sorts the currently selected column.
 o toString()
Returns a text representation of this instance of MultiColumnListbox.
 o update(Graphics)
Don't waste time clearing area; not needed.
 o verticalSeparatorShown()
Returns whether vertical separator lines are shown between each listbox columns. Deprecated.
 o windowActivated(WindowEvent)
 o windowClosed(WindowEvent)
 o windowClosing(WindowEvent)
 o windowDeactivated(WindowEvent)
 o windowDeiconified(WindowEvent)
 o windowIconified(WindowEvent)
 o windowOpened(WindowEvent)

Variables

 o serialVersionUID
 public static final long serialVersionUID
Standard *** private final static boolean REGISTERED = false; /

 o DEFAULT_KEY
 public static final Object DEFAULT_KEY
Default row key value (null).

 o DEFAULT_ROW_HEIGHT
 public static final int DEFAULT_ROW_HEIGHT
Default row height (20).

 o DEFAULT_CAPTIONBAR_HEIGHT
 public static final int DEFAULT_CAPTIONBAR_HEIGHT
Default caption bar height.

 o DEFAULT_SELECTION_BACKGROUND
 public static final Color DEFAULT_SELECTION_BACKGROUND
Default selected background color (Color.gray).

 o DEFAULT_SELECTION_FOREGROUND
 public static final Color DEFAULT_SELECTION_FOREGROUND
Default selected foreground color (Color.black).

 o DEFAULT_BACKGROUND_COLOR
 public static final Color DEFAULT_BACKGROUND_COLOR
Default background color (Color.lightGray).

 o DEFAULT_FOREGROUND_COLOR
 public static final Color DEFAULT_FOREGROUND_COLOR
Default foreground color (Color.black).

 o DEFAULT_SEPARATOR_COLOR
 public static final Color DEFAULT_SEPARATOR_COLOR
Default separator color (Color.black).

 o bar
 protected CaptionBar bar
 o rowheight
 protected int rowheight
 o columns
 protected Vector columns
 o selected
 protected transient BitSet selected
 o sepcolor
 protected Color sepcolor
 o vsep
 protected boolean vsep
 o hsep
 protected boolean hsep
 o lastselected
 protected transient int lastselected
 o background
 protected transient Image background

Constructors

 o MultiColumnListbox
 public MultiColumnListbox()
Constructor. Constructs a new MultiColumnListbox ready to be populated with columns and rows of data.

See Also:
addColumn, addRow

Methods

 o setLayout
 public void setLayout(LayoutManager manager)
Cannot reset the layout manager of this widget.

Overrides:
setLayout in class Container
 o getSelectedColumnIndex
 public int getSelectedColumnIndex()
Returns the index of the selected column.

 o getSelectedObjects
 public Object[] getSelectedObjects()
Returns an array of selected row arrays.

See Also:
ItemListener
 o addItemListener
 public void addItemListener(ItemListener listener)
Adds an item listener. Listeners can be notified of row selection/deselection events through the Java ItemListener interface call. Using ListboxListener is preferred; item listeners are provided for convenience.

See Also:
removeItemListener
 o removeItemListener
 public void removeItemListener(ItemListener listener)
Removes an item listener

See Also:
addItemListener
 o setSeparatorColor
 public void setSeparatorColor(Color color)
Sets the color of the horizontal and vertical separators.

Parameters:
color - The new separator color.
See Also:
getSeparatorColor
 o getSeparatorColor
 public Color getSeparatorColor()
Returns the current color of the horizontal and vertical separators.

See Also:
setSeparatorColor
 o setUpdate
 public void setUpdate(boolean update)
Sets whether updates occur. When updates are turned off operations that normally would cause the listbox to be repainted will not paint. A repaint is called for you when updates are turned back on.

Parameters:
update - False to turn updates off; true to turn back on.
See Also:
getUpdate
 o getUpdate
 public boolean getUpdate()
Returns whether update are turned on or off.

See Also:
setUpdate
 o setName
 public void setName(String name)
Sets the name of the component.

Overrides:
setName in class Component
 o getName
 public String getName()
Returns a unique name for this listbox.

Overrides:
getName in class Component
 o isFocusTraversable
 public boolean isFocusTraversable()
The listbox is always traversable.

Overrides:
isFocusTraversable in class Component
 o focusGained
 public void focusGained(FocusEvent evt)
When focus is gained, redraws the listbox indicating the focus. In other words, the last selected row is drawn with a dotted border.

 o focusLost
 public void focusLost(FocusEvent evt)
When focus is lost, redraw the list without focus indicator.

 o setCaptionBarBackground
 public void setCaptionBarBackground(Color color)
Sets the background color of the caption bar.

 o getCaptionBarBackground
 public Color getCaptionBarBackground()
Returns the current background color of the caption bar.

 o setCaptionBarForeground
 public void setCaptionBarForeground(Color color)
Sets the foreground color of the caption bar.

 o getCaptionBarForeground
 public Color getCaptionBarForeground()
Returns the current foreground color of the caption bar.

 o autoSizeColumn
 public void autoSizeColumn(int index)
Resizes the specified column to fit the widest element currently in the column.

Parameters:
index - The column to resize
 o horizontalScrollAdjustment
 protected void horizontalScrollAdjustment()
Readjusts caption bar and list area. Internal use only.

 o resetVerticalScrollbar
 protected void resetVerticalScrollbar()
Resets the vertical scrollbar -- internal to listbox.

 o resetHorizontalScrollbar
 protected void resetHorizontalScrollbar()
Resets the horizontal scrollbar -- internal to listbox.

 o setCaptionBarVisible
 public void setCaptionBarVisible(boolean visible)
Shows or hides the caption bar.

Parameters:
visible - True to show, false to hide.
See Also:
isCaptionBarVisible
 o isCaptionBarVisible
 public boolean isCaptionBarVisible()
Returns whether or not the caption bar is being shown.

See Also:
setCaptionBarVisible
 o setCaptionBarHeight
 public void setCaptionBarHeight(int height)
Sets the size of the caption bar to the specified height.

Parameters:
height - The new height of the caption bar.
See Also:
DEFAULT_CAPTIONBAR_HEIGHT, getCaptionBarHeight
 o getCaptionBarHeight
 public int getCaptionBarHeight()
Returns the current caption bar height.

See Also:
setCaptionBarHeight
 o setContinuousDrag
 public void setContinuousDrag(boolean realtime)
Sets whether the columns are resized as the caption is resized or only at the end of the drag.

Parameters:
realtime - True if column resized with caption; false if not.
See Also:
getContinuousDrag
 o getContinuousDrag
 public boolean getContinuousDrag()
Returns whether the columns are resized as the caption is resized or only at the end of the drag.

See Also:
setContinuousDrag
 o setRowHeight
 public void setRowHeight(int height)
Sets the height of the listbox rows.

Parameters:
height - The new height.
See Also:
getRowHeight
 o getRowHeight
 public int getRowHeight()
Returns the current height of the listbox rows.

See Also:
setRowHeight
 o selectColumn
 public void selectColumn(int column)
Selects the specified column.

Parameters:
column - The index of the column to select.
See Also:
ListboxColumn, addColumn, getColumn, replaceColumn
 o makeRowVisible
 public void makeRowVisible(int row)
Makes the specified row index visible in the listbox.

 o countColumns
 public int countColumns()
Note: countColumns() is deprecated. Use getColumnCount().

Returns the number of columns in the listbox.

 o getColumnCount
 public int getColumnCount()
Returns the number of columns in the listbox.

Returns:
Number of columns.
See Also:
addColumn, getColumnInfo
 o sort
 public void sort()
Sorts the currently selected column.

See Also:
isSortable, setSorter
 o setMultipleSelections
 public void setMultipleSelections(boolean allow)
Sets whether multiple selections are allowed in the listbox.

Parameters:
allow - Set to true if multiple selections are allowed.
See Also:
getMultipleSelections, selectRow, deselectRow
 o allowsMultipleSelections
 public boolean allowsMultipleSelections()
Note: allowsMultipleSelections() is deprecated. Use getMultipleSelections().

Returns whether multiple selections are allowed.

 o getMultipleSelections
 public boolean getMultipleSelections()
Returns whether multiple selections are allowed.

See Also:
setMultipleSelections
 o selectRow
 public void selectRow(int row)
Selects a row.

Parameters:
row - Which row to select.
See Also:
deselectRow, selectAllRows, selectRowByKey
 o selectAllRows
 public void selectAllRows()
Selects all of the rows. If this listbox doesn't allow multiple selections, then no rows are selected.

See Also:
deselectAllRows, selectRow, selectRowByKey
 o selectRowByKey
 public void selectRowByKey(Object key)
Selects the first row with the given key.

Parameters:
key - The key to search for.
See Also:
deselectRowByKey, selectRow, selectAllRows
 o deselectRow
 public void deselectRow(int row)
Deselects a row.

Parameters:
row - The row to deselect.
See Also:
deselectAllRows, deselectRowByKey, selectRow
 o deselectAllRows
 public void deselectAllRows()
Deselects all of the rows.

See Also:
deselectRow, deselectRowByKey, selectAllRows
 o deselectRowByKey
 public void deselectRowByKey(Object key)
Deselects the first row with the given key.

Parameters:
key - The key of the row to deselect.
See Also:
deselectRow, deselectAllRows, selectRowByKey
 o countRows
 public int countRows()
Note: countRows() is deprecated. Use getRowCount().

Returns the number of rows in the listbox.

 o getRowCount
 public int getRowCount()
Returns the number of rows in the listbox.

See Also:
getColumnCount
 o showHorizontalSeparator
 public void showHorizontalSeparator()
Note: showHorizontalSeparator() is deprecated. Use setHorizontalSeparatorVisible(true).

Shows a horizontal separator line between each row.

 o hideHorizontalSeparator
 public void hideHorizontalSeparator()
Note: hideHorizontalSeparator() is deprecated. Use setHorizontalSeparatorVisible(false).

Hides a horizontal separator line between each row.

 o setHorizontalSeparatorVisible
 public void setHorizontalSeparatorVisible(boolean visible)
Shows or hides a horizontal separator line between each row.

Parameters:
visible - True to show horizontal separator, false otherwise.
See Also:
isHorizontalSeparatorVisible
 o horizontalSeparatorShown
 public boolean horizontalSeparatorShown()
Note: horizontalSeparatorShown() is deprecated. Use isHorizontalSeparatorVisible().

Returns whether horizontal separator lines are shown between each listbox row.

 o isHorizontalSeparatorVisible
 public boolean isHorizontalSeparatorVisible()
Returns whether horizontal separator lines are shown between each listbox row.

See Also:
setHorizontalSeparatorVisible
 o showVerticalSeparator
 public void showVerticalSeparator()
Note: showVerticalSeparator() is deprecated. Use setVerticalSeparatorVisible(true).

Shows a vertical separator line between each column.

 o hideVerticalSeparator
 public void hideVerticalSeparator()
Note: hideVerticalSeparator() is deprecated. Use setVerticalSeparatorVisible(false).

Hides a vertical separator line between each column.

 o setVerticalSeparatorVisible
 public void setVerticalSeparatorVisible(boolean visible)
Show or hides a vertical separator line between each column.

Parameters:
visible - True to show, false to hide.
See Also:
isVerticalSeparatorVisible, setHorizontalSeparatorVisible
 o verticalSeparatorShown
 public boolean verticalSeparatorShown()
Note: verticalSeparatorShown() is deprecated. Use isVerticalSeparatorVisible().

Returns whether vertical separator lines are shown between each listbox columns.

 o isVerticalSeparatorVisible
 public boolean isVerticalSeparatorVisible()
Returns whether the vertical separators are being shown.

See Also:
setVerticalSeparatorVisible
 o addColumn
 public ListboxColumn addColumn(String title)
Adds a column to the listbox.

Parameters:
title - The title of this column.
Returns:
Returns a reference to the new column.
See Also:
addColumns, replaceColumn, removeColumn, getColumnInfo, ListboxColumn
 o addColumns
 public void addColumns(String captions[])
Adds a series of columns to the listbox.

Parameters:
captions - An array containing the titles of the columns to be added.
See Also:
addColumn
 o deleteColumn
 public void deleteColumn(int index)
Note: deleteColumn() is deprecated. Use removeColumn().

Removes a column from the listbox.

 o removeColumn
 public void removeColumn(int index)
Removes a column from the listbox.

Parameters:
index - The index of the column to remove.
See Also:
removeAllColumns, addColumn
 o removeAllColumns
 public void removeAllColumns()
Removes all of the columns from the listbox.

See Also:
removeColumn
 o getColumnInfo
 public ListboxColumn getColumnInfo(int column)
Returns a reference to specified column or null if no such column index exists.

Parameters:
column - The column to return.
 o addRow
 public void addRow(Object elements[])
Add a new row to the multi-column listbox with the default key value.

Parameters:
elements - An array of objects to add to the listbox, one for each column. If there are too few elements, blank strings are added in their place. If too many strings are sent in, they are ignored.
See Also:
addRow, addRows, insertRow, removeRow, getRow, DEFAULT_KEY
 o addRow
 public void addRow(Object elements[],
                    Object key)
Add a new row to the multi-column listbox with a given key. The key can be used by the programmer to associate hash values to individual rows of data so that those rows can be retrieved

Parameters:
elements - An array of objects to add to the listbox, one for each column. If there are too few elements, blank strings are added in their place. If too many strings are sent in, they are ignored.
key - The associated key for this row.
See Also:
addRow, addRows
 o addRows
 public void addRows(Object rows[][])
Adds a series of rows with the default key value.

Parameters:
rows - An array of row arrays. For example: if you have two columns ("First" and "Last", respectively) then you would assign rows = { { "Charlie", "Cleveland" }, { "Eugene", "Shumulinsky" }, { "Tad", "Kollar" } }; .
See Also:
addRow
 o addRows
 public void addRows(Object rows[][],
                     Object keys[])
Adds a series of rows with the specified key values.

Parameters:
rows - An array of row arrays. For example: if you have two columns ("First" and "Last", respectively) then you would assign rows to { { "Charlie", "Cleveland" }, { "Eugene", "Shumulinsky" }, { "Tad", "Kollar" } } .
keys - An array of key values. If there fewer keys than rows, then the row is assigned the default key value. If too many keys are sent, they extra key values are ignored.
See Also:
addRow, getRow, replaceRow, removeRow, DEFAULT_KEY
 o insertRow
 public void insertRow(Object elements[],
                       int where)
Inserts a row of data into the listbox with the default key value.

Parameters:
elements - The row of data to insert.
where - Which row to insert new row before.
See Also:
DEFAULT_KEY, insertRows, addRow, getRow, removeRow, replaceRow
 o insertRow
 public void insertRow(Object elements[],
                       Object key,
                       int where)
Inserts a row of data into the listbox.

Parameters:
elements - The row of data to insert.
key - The key for this row of data
where - Which row to insert new row before.
 o insertRows
 public void insertRows(Object rows[][],
                        int where)
Inserts the given rows at the specified index with the default key value.

Parameters:
rows - The rows to insert.
where - The index where to insert.
See Also:
insertRow
 o insertRows
 public void insertRows(Object rows[][],
                        Object keys[],
                        int where)
Inserts the given rows at the specified index and the key values.

Parameters:
rows - The rows to insert.
keys - The key values for the rows.
where - The index where to insert.
See Also:
insertRow
 o replaceRow
 public void replaceRow(Object elements[],
                        int row)
Replaces all elements of the given row with the text strings specified. If the array of String elements does not contain the same number of elements for the number of columns in the listbox, blank Strings are used to replace the old values. If too many elements are given, the extra elements are ignored.

Parameters:
elements - The array of new values.
row - Which row to modify.
See Also:
addRow, getRow, removeRow
 o replaceColumn
 public void replaceColumn(Object elements[],
                           int col)
Replaces the elements in the given column with the array of objects specified. If the array of objects does not contain the same number of elements for the number of rows in the listbox, blank strings are used to replace the old values. If too many elements are given, the extra elements are ignored.

Parameters:
elements - The array of new values.
col - Which column to replace.
See Also:
addColumn, addColumns, getRow, removeColumn, ListboxColumn
 o deleteRow
 public void deleteRow(int row)
Note: deleteRow() is deprecated. Use removeRow().

Removes a row from the listbox.

 o removeRow
 public void removeRow(int row)
Removes a row from the listbox.

Parameters:
row - The row to remove.
See Also:
removeRows, getRow, addRow, replaceRow
 o removeRows
 public void removeRows(int row,
                        int num)
Removes a series of rows.

Parameters:
row - The row to start removing from.
num - The number of rows to remove.
See Also:
removeRow
 o getSelectedIndex
 public int getSelectedIndex()
Returns the index of the first selected row or -1 if no row is selected.

See Also:
selectRow, deselectRow, getSelectedIndexes, getSelectedRow, getSelectedRows
 o getSelectedIndexes
 public int[] getSelectedIndexes()
Returns an array of indexes of the selected rows. If no rows were selected, the length of the returned array will be 0.

See Also:
selectRow, deselectRow, getSelectedIndex, getSelectedRow, getSelectedRows
 o getSelectedRow
 public Object[] getSelectedRow()
Returns the first selected row. If no rows are selected, the length of the returned array will be 0.

See Also:
getSelectedRows, getSelectedIndex, getSelectedIndexes, selectRow
 o getSelectedRows
 public Object[][] getSelectedRows()
Returns all of the selected rowsas an array of rows.

See Also:
getSelectedRow
 o getColumn
 public Object[] getColumn(int column)
Returns the array of values in the column, or null if column specified is invalid.

Parameters:
column - The column to return.
See Also:
addColumn
 o getRow
 public Object[] getRow(int index)
Returns the array of values in the row, or null if row specified is invalid.

Parameters:
index - The row to return.
See Also:
addRow
 o getKeys
 public Object[] getKeys()
Returns the array of key values, or null if there are no columns or rows in the list.

See Also:
getRowKey, getRowByKey, getIndexByKey
 o getRowByKey
 public Object[] getRowByKey(Object key)
Returns an array of row values with the specified key or null if no row has the specified key. If multiple rows have the same key value, then the first row with the matching key will be returned.

Parameters:
key - The key of the row to return.
See Also:
getKeys, getRowKey, getIndexByKey
 o getIndexByKey
 public int getIndexByKey(Object key)
Returns the index of the first row that has the specified key or -1 if no row has that key.

Parameters:
key - The key of the row index to return.
See Also:
getKeys, getRowKey, getRowByKey
 o setRowKey
 public void setRowKey(Object key,
                       int row)
Sets the key to the specified row.

Parameters:
key - The new key.
row - The row to modify.
See Also:
getKeys, getRowKey, getRowByKey, getIndexByKey
 o getRowKey
 public Object getRowKey(int row)
Returns the key value for the specified row.

Parameters:
row - The row to return the key for.
See Also:
setRowKey
 o clear
 public void clear()
Note: clear() is deprecated. Use removeAllRows().

Removes all the rows from the listbox.

 o removeAllRows
 public void removeAllRows()
Removes all the rows from the listbox.

See Also:
addRow, setRowKey
 o setVerticalScrollbarVisible
 public void setVerticalScrollbarVisible(boolean visible)
Shows or hides the vertical scrollbar.

Parameters:
visible - True to show, false to hide.
See Also:
isVerticalScrollbarVisible
 o isVerticalScrollbarVisible
 public boolean isVerticalScrollbarVisible()
Returns whether the vertical scrollbar is shown.

See Also:
setVerticalScrollbarVisible
 o setHorizontalScrollbarVisible
 public void setHorizontalScrollbarVisible(boolean visible)
Shows or hides the horizontal scrollbar.

Parameters:
visible - True to show, false to hide.
See Also:
isHorizontalScrollbarVisible
 o isHorizontalScrollbarVisible
 public boolean isHorizontalScrollbarVisible()
Returns whether the horizontal scrollbar is shown.

See Also:
setHorizontalScrollbarVisible
 o setBounds
 public void setBounds(int x,
                       int y,
                       int w,
                       int h)
Reshapes the listbox and all the internal components.

Parameters:
x - X coordinate.
y - Y coordinate.
w - Width.
h - Height.
Overrides:
setBounds in class Component
 o getPreferredSize
 public Dimension getPreferredSize()
Returns the preferred size of the listbox which is just the minimum size.

Overrides:
getPreferredSize in class Container
 o getMinimumSize
 public Dimension getMinimumSize()
Returns the minimum size of this component.

Overrides:
getMinimumSize in class Container
 o setSelectionBackground
 public void setSelectionBackground(Color color)
Sets the background color for all selected rows.

Parameters:
color - The new selected row background color.
See Also:
getSelectionForeground, getSelectionBackground, setSelectionForeground
 o getSelectionBackground
 public Color getSelectionBackground()
Gets the current background color for all selected rows.

Returns:
Returns the selected row background color.
See Also:
getSelectionForeground, setSelectionForeground, setSelectionBackground
 o setSelectionForeground
 public void setSelectionForeground(Color color)
Sets the foreground color for all selected rows.

Parameters:
color - The new selected row foreground color.
See Also:
getSelectionForeground, getSelectionBackground, setSelectionBackground
 o getSelectionForeground
 public Color getSelectionForeground()
Gets the foreground color for all selected rows.

Returns:
Returns the current selected row foreground color.
See Also:
getSelectionBackground, setSelectionForeground, setSelectionBackground
 o showBorder
 public void showBorder()
Note: showBorder() is deprecated.

Shows a border around the listbox.

 o hideBorder
 public void hideBorder()
Note: hideBorder() is deprecated.

Hides the border around the listbox.

 o setBackgroundImage
 public void setBackgroundImage(Image image)
Sets the background image for drawing. Because java.awt.Image is not currently serializable, the background image will not be serialized when this object is serialized.

Parameters:
image - The new background image.
See Also:
getBackgroundImage
 o getBackgroundImage
 public Image getBackgroundImage()
Returns the current background image or null if none is set.

See Also:
setBackgroundImage
 o setCaptionBarBackgroundImage
 public void setCaptionBarBackgroundImage(Image image)
Sets the background image of the caption bar.

Parameters:
image - The new background image.
See Also:
getBackgroundImage
 o getCaptionBarBackgroundImage
 public Image getCaptionBarBackgroundImage()
Returns the current background image of the caption bar or null if none is set.

See Also:
setBackgroundImage
 o update
 public void update(Graphics g)
Don't waste time clearing area; not needed.

Overrides:
update in class Component
 o paint
 public void paint(Graphics g)
Paints the listbox.

Overrides:
paint in class Container
 o repaint
 public void repaint()
Repaint caption bar and list area.

Overrides:
repaint in class Component
 o keyTyped
 public void keyTyped(KeyEvent evt)
A key was typed.

 o keyPressed
 public void keyPressed(KeyEvent evt)
A key was pressed.

 o keyReleased
 public void keyReleased(KeyEvent evt)
A key was released.

 o adjustmentValueChanged
 public void adjustmentValueChanged(AdjustmentEvent evt)
A scrollbar was adjusted.

 o mouseClicked
 public void mouseClicked(MouseEvent evt)
A mouse button was clicked.

 o mousePressed
 public void mousePressed(MouseEvent evt)
A mouse button was pressed.

 o mouseReleased
 public void mouseReleased(MouseEvent evt)
A mouse button was released.

 o mouseEntered
 public void mouseEntered(MouseEvent evt)
The mouse cursor entered the component.

 o mouseExited
 public void mouseExited(MouseEvent evt)
The mouse cursor exited the component.

 o captionSelected
 public synchronized void captionSelected(CaptionBarEvent evt)
A caption was selected.

 o captionResized
 public void captionResized(CaptionBarEvent evt)
A caption was resized.

 o addCaptionBarListener
 public void addCaptionBarListener(CaptionBarListener listener)
Adds a caption bar event listener.

Parameters:
listener - The listener to add.
See Also:
removeCaptionBarListener
 o removeCaptionBarListener
 public void removeCaptionBarListener(CaptionBarListener listener)
Removes a caption bar event listener.

Parameters:
listener - The listener to remove.
See Also:
addCaptionBarListener
 o addListboxListener
 public void addListboxListener(ListboxListener listener)
Adds a listbox event listener.

Parameters:
listener - The listener to add.
See Also:
removeListboxListener
 o removeListboxListener
 public void removeListboxListener(ListboxListener listener)
Removes a listbox event listener.

Parameters:
listener - The listener to remove.
See Also:
addListboxListener
 o addAdjustmentListener
 public void addAdjustmentListener(AdjustmentListener listener,
                                   int scrollbar)
Adds a scrollbar adjustment listener.

Parameters:
listener - The listener to add.
scrollbar - The orientation of the scrollbar to listen to (e.g. Scrollbar.VERTICAL).
See Also:
removeAdjustmentListener, VERTICAL, HORIZONTAL
 o removeAdjustmentListener
 public void removeAdjustmentListener(AdjustmentListener listener,
                                      int scrollbar)
Removes a scrollbar adjustment listener.

Parameters:
listener - The listener to remove.
scrollbar - The orientation of the scrollbar.
See Also:
addAdjustmentListener, VERTICAL, HORIZONTAL
 o paintHook
 protected String paintHook(String s,
                            int row,
                            int col)
This hook allows descendant classes to change the text of a specific entry *before* it's printed but without changing the data stored in the element. To use this hook, derive from MultiColumnListbox and override paintHook to modify the incoming string, s, and return a new string modified to provide such behavior as name shortening, etc.

Parameters:
s - The original text string
row - The row of this element.
col - The column of this element.
Returns:
Returns the modified string that will be drawn. The base class version of this method simply returns the incoming string, s.
 o toString
 public String toString()
Returns a text representation of this instance of MultiColumnListbox.

Returns:
Returns string representation of listbox.
Overrides:
toString in class Component
 o actionPerformed
 public void actionPerformed(ActionEvent evt)
 o windowClosing
 public void windowClosing(WindowEvent evt)
 o windowOpened
 public void windowOpened(WindowEvent evt)
 o windowClosed
 public void windowClosed(WindowEvent evt)
 o windowIconified
 public void windowIconified(WindowEvent evt)
 o windowDeiconified
 public void windowDeiconified(WindowEvent evt)
 o windowActivated
 public void windowActivated(WindowEvent evt)
 o windowDeactivated
 public void windowDeactivated(WindowEvent evt)

All Packages  Class Hierarchy  This Package  Previous  Next  Index