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 TableListener, CaptionBarListener, ItemSelectable, MouseListener, KeyListener, AdjustmentListener
The Taligent MultiColumnListbox Bean allows Java programmers to
add multi-column listboxes to your applets and applications with
relative ease. Columns can be resized by the user and can be
sorted using any sorting algorithm you want. In addition, you can
set specific colors for each column, and even insert graphical
elements anywhere in the listbox. The listbox can even handle
Java components added as elements!
The new version provides better operability with existing
development environments like IBM's VisualAge for Java and a
concise data model while maintaining the same easy to use API!
Check it out for yourself and you'll see why this listbox is so
popular.
History:
- 1.0: Initial writing. (Java 1.0.2 only)
- 2.0: Bean version. (Java 1.1 or higher)
- Added 100% Java scrollbar
- Added horizontal scrolling
- Caption resize line changed to resize cursor
- Renamed methods to match Bean specification
- Rounded out data access methods
- Bug fixes
- 3.0: TableModel version.
- Added TableModel as data source
- Added powerful extension method hooks
- Scrollbars only appear when needed
- Smooth horizontal scrolling
- Bug fixes
- Version:
- 3.0
- Author:
- Andy Clark, Taligent Inc.
- See Also:
- TableModel, CaptionBar, ListboxColumn
-
DEFAULT_BACKGROUND_COLOR
- Default background color (Color.lightGray).
-
DEFAULT_CAPTIONBAR_HEIGHT
- Default caption bar height (20).
-
DEFAULT_FOREGROUND_COLOR
- Default foreground color (Color.black).
-
DEFAULT_KEY
- Default row key value (null).
-
DEFAULT_ROW_HEIGHT
- Default row height (20).
-
DEFAULT_SELECTION_BACKGROUND
- Default selected background color (Color.gray).
-
DEFAULT_SELECTION_FOREGROUND
- Default selected foreground color (Color.black).
-
DEFAULT_SEPARATOR_COLOR
- Default separator color (Color.black).
-
MultiColumnListbox()
- Default constructor.
-
MultiColumnListbox(TableModel)
- Constructs a listbox view with the given table.
-
addAdjustmentListener(AdjustmentListener, int)
- Adds a scrollbar adjustment listener.
Deprecated.
-
addCaptionBarListener(CaptionBarListener)
- Adds a caption bar event listener.
-
addColumn(Object)
- Adds a column to the listbox.
-
addColumns(Object[])
- Adds a series of columns to the listbox.
-
addItemListener(ItemListener)
- Adds an item listener.
-
addKeyListener(KeyListener)
- Adds a key listener.
-
addListboxListener(ListboxListener)
- Adds a listbox event listener.
-
addMouseListener(MouseListener)
- Adds a mouse listener.
-
addMouseMotionListener(MouseMotionListener)
- Adds a mouse motion listener.
-
addRow(Object[])
- Add a new row to the multi-column listbox with the default key
value.
-
addRow(Object[], Object)
- Add a new row to the multi-column listbox with a given key.
-
addRows(Object[][])
- Adds a series of rows with the default key value.
-
addRows(Object[][], Object[])
- Adds a series of rows with the specified key values.
-
adjustmentValueChanged(AdjustmentEvent)
- Adjustment value changed.
-
allowSelection(ListboxEvent)
- This function acts as a mask to allow/disallow selection
given a specific row, column, and relative (x,y) within it.
-
autoSizeColumn(int)
- Resizes the specified column to fit the widest element
currently in the column.
-
captionResized(CaptionBarEvent)
- A caption was resized.
-
captionSelected(CaptionBarEvent)
- A caption was selected.
-
columnAdded(TableEvent)
- A column was added.
-
columnChanged(TableEvent)
- Column was changed.
-
columnInfoChanged(TableEvent)
- Column information changed.
-
columnInserted(TableEvent)
- A column was inserted.
-
columnRemoved(TableEvent)
- A column was removed.
-
createCaption()
- This function is a "factory" method that creates a listbox
caption.
-
deliverEvent(EventObject)
- This function delivers listbox related events.
-
deselectAllRows()
- Deselects all of the rows.
-
deselectRow(int)
- Deselects a row.
-
deselectRowByKey(Object)
- Deselects the first row with the specified key.
-
elementChanged(TableEvent)
- An element's data changed.
-
getBackgroundImage()
- Returns the current background image or null if none
is set.
-
getCaptionBarBackground()
- Returns the current background color of the caption bar.
-
getCaptionBarBackgroundImage()
- Returns the current background image of the caption bar
or null if none is set.
-
getCaptionBarForeground()
- Returns the current foreground color of the caption bar.
-
getCaptionBarHeight()
- Returns the current caption bar height.
-
getColumn(int)
- Returns the array of values in the column, or null if
column specified is invalid.
-
getColumnCount()
- Returns the number of columns in the listbox.
-
getColumnInfo(int)
- Returns a reference to specified column or null if no
such column index exists.
-
getContinuousDrag()
- Returns whether the columns are resized as the
caption is resized or only at the end of the drag.
-
getHorizontalAdjuster()
- Returns the horizontal adjuster.
-
getIndexByKey(Object)
- Returns the index of the first row that has the specified
key or -1 if no row has that key.
-
getKeys()
- Returns the array of key values, or null if there are
no columns or rows in the list.
-
getMinimumSize()
- Returns the minimum size required for the view.
-
getModel()
- Returns the model.
-
getMultipleSelections()
- Returns whether multiple selections are allowed.
-
getPreferredSize()
- Returns the preferred size for the view.
-
getRow(int)
- Returns the array of values in the row, or null if
row specified is invalid.
-
getRowByKey(Object)
- Returns an array of row values with the specified key or
null if no row has the specified key.
-
getRowCount()
- Returns the number of rows in the listbox.
-
getRowHeight()
- Returns the current height of the listbox rows.
-
getRowKey(int)
- Returns the key value for the specified row.
-
getSelectedColumnIndex()
- Returns the index of the selected column.
-
getSelectedIndex()
- Returns the index of the first selected row or -1 if
no row is selected.
-
getSelectedIndexes()
- Returns an array of indexes of the selected rows.
-
getSelectedObjects()
- Returns an array of selected row arrays.
-
getSelectedRow()
- Returns the first selected row.
-
getSelectedRows()
- Returns all of the selected rows as an array of rows.
-
getSelectionBackground()
- Gets the current background color for all selected rows.
-
getSelectionForeground()
- Gets the foreground color for all selected rows.
-
getSeparatorColor()
- Returns the current color of the horizontal and vertical
separators.
-
getUpdate()
- Returns whether update are turned on or off.
-
getVerticalAdjuster()
- Returns the vertical adjuster.
-
insertRow(Object[], int)
- Inserts a row of data into the listbox with the default
key value.
-
insertRow(Object[], Object, int)
- Inserts a row of data into the listbox.
-
insertRows(Object[][], int)
- Inserts the given rows at the specified index with the
default key value.
-
insertRows(Object[][], Object[], int)
- Inserts the given rows at the specified index and the
key values.
-
invertSelections()
- Inverts the selected rows -- selected rows become deselected
and deselected rows become selected.
-
isBorderVisible()
- Returns true if the listbox border is showing, false otherwise.
-
isCaptionBarVisible()
- Returns whether or not the caption bar is being shown.
-
isFocusTraversable()
- The listbox is always traversable.
-
isHorizontalScrollbarVisible()
- Returns whether the horizontal scrollbar is shown.
Deprecated.
-
isHorizontalSeparatorVisible()
- Returns whether horizontal separator lines are shown between
each listbox row.
-
isSelectable()
- Returns true if the listbox is selectable, false otherwise.
-
isVerticalScrollbarVisible()
- Returns whether the vertical scrollbar is shown.
Deprecated.
-
isVerticalSeparatorVisible()
- Returns whether the vertical separators are being shown.
-
keyPressed(KeyEvent)
- A key was pressed.
-
keyReleased(KeyEvent)
- A key was released.
-
keyTyped(KeyEvent)
- A key was typed.
-
listboxColumnToTableColumn(int)
- Returns the physical table column associated with the specified
listbox column, or -1 if no mapping exists.
-
listboxRowToTableRow(int)
- Returns the physical table row associated with the specified
listbox row, or -1 if no mapping exists.
-
makeRowVisible(int)
- Makes the specified row index visible in the listbox.
-
mouseClicked(MouseEvent)
- A mouse button was clicked.
-
mouseEntered(MouseEvent)
- The mouse cursor entered the component.
-
mouseExited(MouseEvent)
- The mouse cursor exited the component.
-
mousePressed(MouseEvent)
- A mouse button was pressed.
-
mouseReleased(MouseEvent)
- A mouse button was released.
-
paint(Graphics)
- Handles painting of the border.
-
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.
-
removeAdjustmentListener(AdjustmentListener, int)
- Removes a scrollbar adjustment listener.
Deprecated.
-
removeAllColumns()
- Removes all of the columns from the listbox.
-
removeAllRows()
- Removes all of the rows from the listbox.
-
removeCaptionBarListener(CaptionBarListener)
- Removes a caption bar event listener.
-
removeColumn(int)
- Removes a column from the listbox.
-
removeItemListener(ItemListener)
- Removes an item listener
-
removeKeyListener(KeyListener)
- Removes a key listener.
-
removeListboxListener(ListboxListener)
- Removes a listbox event listener.
-
removeMouseListener(MouseListener)
- Removes a mouse listener.
-
removeMouseMotionListener(MouseMotionListener)
- Removes a mouse listener.
-
removeRow(int)
- Removes a row from the listbox.
-
removeRows(int, int)
- Removes a series of rows.
-
replaceColumn(Object[], int)
- Replaces the elements in the given column with the array of
objects specified.
-
replaceRow(Object[], int)
- Replaces all elements of the given row with the specified
elements.
-
rowAdded(TableEvent)
- A row was added.
-
rowChanged(TableEvent)
- Row was changed.
-
rowInfoChanged(TableEvent)
- Row information changed.
-
rowInserted(TableEvent)
- A row was inserted.
-
rowRemoved(TableEvent)
- A row was removed.
-
selectAllRows()
- Selects all of the rows.
-
selectColumn(int)
- Selects the specified column.
-
selectRow(int)
- Selects a row.
-
selectRowByKey(Object)
- Selects the first row with the specified key.
-
setBackgroundImage(Image)
- Sets the background image for drawing.
-
setBorderVisible(boolean)
- Shows or hides the listbox border.
-
setBounds(int, int, int, int)
- Sets the bounds of the control.
-
setCaptionBarBackground(Color)
- Sets the background color of the caption bar.
-
setCaptionBarBackgroundImage(Image)
- Sets the background image of the caption bar.
-
setCaptionBarForeground(Color)
- Sets the foreground color of the caption bar.
-
setCaptionBarHeight(int)
- Sets the size of the caption bar to the specified height.
-
setCaptionBarVisible(boolean)
- Shows or hides the caption bar.
-
setContinuousDrag(boolean)
- Sets whether the columns are resized as the caption
is resized or only at the end of the drag.
-
setHorizontalScrollbarVisible(boolean)
- Shows or hides the horizontal scrollbar.
Deprecated.
-
setHorizontalSeparatorVisible(boolean)
- Shows or hides a horizontal separator line between each row.
-
setLayout(LayoutManager)
- Not allowed to reset layout manager.
-
setModel(TableModel)
- Sets the model.
-
setMultipleSelections(boolean)
- Sets whether multiple selections are allowed in the listbox.
-
setRowHeight(int)
- Sets the height of the listbox rows.
-
setRowKey(Object, int)
- Sets the key to the specified row.
-
setSelectable(boolean)
- Sets whether the user is allowed to select rows
in the listbox.
-
setSelectionBackground(Color)
- Sets the background color for all selected rows.
-
setSelectionForeground(Color)
- Sets the foreground color for all selected rows.
-
setSeparatorColor(Color)
- Sets the color of the horizontal and vertical separators.
-
setUpdate(boolean)
- Sets whether updates occur.
-
setVerticalScrollbarVisible(boolean)
- Shows or hides the vertical scrollbar.
Deprecated.
-
setVerticalSeparatorVisible(boolean)
- Show or hides a vertical separator line between each column.
-
sort()
- Sorts the currently selected column.
-
tableChanged(TableEvent)
- Table completely changed.
-
tableRefreshed(TableEvent)
- Table refreshed.
-
toString()
- Returns a text representation of this instance of MultiColumnListbox.
-
update(Graphics)
- public void repaint() {
if (fUpdate) {
// repaint components
fCaptionBar.repaint();
fViewArea.repaint();
fHScrollbar.repaint();
fVScrollbar.repaint();
}
}
/**
Don't clear area -- not needed.
DEFAULT_KEY
public static final Object DEFAULT_KEY
- Default row key value (null).
DEFAULT_ROW_HEIGHT
public static final int DEFAULT_ROW_HEIGHT
- Default row height (20).
DEFAULT_CAPTIONBAR_HEIGHT
public static final int DEFAULT_CAPTIONBAR_HEIGHT
- Default caption bar height (20).
DEFAULT_BACKGROUND_COLOR
public static final Color DEFAULT_BACKGROUND_COLOR
- Default background color (Color.lightGray).
DEFAULT_FOREGROUND_COLOR
public static final Color DEFAULT_FOREGROUND_COLOR
- Default foreground color (Color.black).
DEFAULT_SEPARATOR_COLOR
public static final Color DEFAULT_SEPARATOR_COLOR
- Default separator color (Color.black).
DEFAULT_SELECTION_BACKGROUND
public static final Color DEFAULT_SELECTION_BACKGROUND
- Default selected background color (Color.gray).
DEFAULT_SELECTION_FOREGROUND
public static final Color DEFAULT_SELECTION_FOREGROUND
- Default selected foreground color (Color.black).
MultiColumnListbox
public MultiColumnListbox()
- Default constructor.
MultiColumnListbox
public MultiColumnListbox(TableModel table)
- Constructs a listbox view with the given table.
setLayout
public void setLayout(LayoutManager layout)
- Not allowed to reset layout manager.
- Overrides:
- setLayout in class Container
addMouseListener
public void addMouseListener(MouseListener listener)
- Adds a mouse listener.
- Overrides:
- addMouseListener in class Component
removeMouseListener
public void removeMouseListener(MouseListener listener)
- Removes a mouse listener.
- Overrides:
- removeMouseListener in class Component
addMouseMotionListener
public void addMouseMotionListener(MouseMotionListener listener)
- Adds a mouse motion listener.
- Overrides:
- addMouseMotionListener in class Component
removeMouseMotionListener
public void removeMouseMotionListener(MouseMotionListener listener)
- Removes a mouse listener.
- Overrides:
- removeMouseMotionListener in class Component
addKeyListener
public void addKeyListener(KeyListener listener)
- Adds a key listener.
- Overrides:
- addKeyListener in class Component
removeKeyListener
public void removeKeyListener(KeyListener listener)
- Removes a key listener.
- Overrides:
- removeKeyListener in class Component
setBounds
public synchronized void setBounds(int x,
int y,
int w,
int h)
- Sets the bounds of the control.
- Overrides:
- setBounds in class Component
getPreferredSize
public synchronized Dimension getPreferredSize()
- Returns the preferred size for the view.
- Overrides:
- getPreferredSize in class Container
getMinimumSize
public synchronized Dimension getMinimumSize()
- Returns the minimum size required for the view.
- Overrides:
- getMinimumSize in class Container
addListboxListener
public void addListboxListener(ListboxListener listener)
- Adds a listbox event listener.
- Parameters:
- listener - The listener to add.
- See Also:
- removeListboxListener
removeListboxListener
public void removeListboxListener(ListboxListener listener)
- Removes a listbox event listener.
- Parameters:
- listener - The listener to remove.
- See Also:
- addListboxListener
addCaptionBarListener
public void addCaptionBarListener(CaptionBarListener listener)
- Adds a caption bar event listener.
- Parameters:
- listener - The listener to add.
- See Also:
- removeCaptionBarListener
removeCaptionBarListener
public void removeCaptionBarListener(CaptionBarListener listener)
- Removes a caption bar event listener.
- Parameters:
- listener - The listener to remove.
- See Also:
- addCaptionBarListener
addAdjustmentListener
public void addAdjustmentListener(AdjustmentListener listener,
int scrollbar)
- Note: addAdjustmentListener() is deprecated.
Use getHorizontalAdjustor and getVerticalAdjuster
to obtain an Adjustable object reference for the
horizontal and vertical scrollbars, respectively.
With that reference, you can add and remove
adjustment listeners.
- Adds a scrollbar adjustment listener.
- Parameters:
- listener - The listener to add.
- scrollbar - The orientation of the scrollbar to
listen to (e.g. Scrollbar.VERTICAL).
removeAdjustmentListener
public void removeAdjustmentListener(AdjustmentListener listener,
int scrollbar)
- Note: removeAdjustmentListener() is deprecated.
Use getHorizontalAdjustor and getVerticalAdjuster
to obtain an Adjustable object reference for the
horizontal and vertical scrollbars, respectively.
With that reference, you can add and remove
adjustment listeners.
- Removes a scrollbar adjustment listener.
- Parameters:
- listener - The listener to remove.
- scrollbar - The orientation of the scrollbar.
getHorizontalAdjuster
public Adjustable getHorizontalAdjuster()
- Returns the horizontal adjuster.
getVerticalAdjuster
public Adjustable getVerticalAdjuster()
- Returns the vertical adjuster.
setModel
public synchronized void setModel(TableModel table)
- Sets the model.
getModel
public TableModel getModel()
- Returns the model.
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
removeItemListener
public void removeItemListener(ItemListener listener)
- Removes an item listener
- See Also:
- addItemListener
getSelectedObjects
public Object[] getSelectedObjects()
- Returns an array of selected row arrays.
- See Also:
- ItemListener
sort
public synchronized void sort()
- Sorts the currently selected column.
- See Also:
- isSortable, setSorter
isFocusTraversable
public boolean isFocusTraversable()
- The listbox is always traversable.
- Overrides:
- isFocusTraversable in class Component
setSeparatorColor
public void setSeparatorColor(Color color)
- Sets the color of the horizontal and vertical separators.
- Parameters:
- color - The new separator color.
- See Also:
- getSeparatorColor
getSeparatorColor
public Color getSeparatorColor()
- Returns the current color of the horizontal and vertical
separators.
- See Also:
- setSeparatorColor
setUpdate
public synchronized 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
getUpdate
public boolean getUpdate()
- Returns whether update are turned on or off.
- See Also:
- setUpdate
setCaptionBarBackground
public void setCaptionBarBackground(Color color)
- Sets the background color of the caption bar.
getCaptionBarBackground
public Color getCaptionBarBackground()
- Returns the current background color of the caption bar.
setCaptionBarForeground
public void setCaptionBarForeground(Color color)
- Sets the foreground color of the caption bar.
getCaptionBarForeground
public Color getCaptionBarForeground()
- Returns the current foreground color of the caption bar.
setCaptionBarVisible
public void setCaptionBarVisible(boolean visible)
- Shows or hides the caption bar.
- Parameters:
- visible - True to show, false to hide.
- See Also:
- isCaptionBarVisible
isCaptionBarVisible
public boolean isCaptionBarVisible()
- Returns whether or not the caption bar is being shown.
- See Also:
- setCaptionBarVisible
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
getCaptionBarHeight
public int getCaptionBarHeight()
- Returns the current caption bar height.
- See Also:
- setCaptionBarHeight
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
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
setRowHeight
public synchronized void setRowHeight(int height)
- Sets the height of the listbox rows.
- Parameters:
- height - The new height.
- See Also:
- getRowHeight
getRowHeight
public int getRowHeight()
- Returns the current height of the listbox rows.
- See Also:
- setRowHeight
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
getMultipleSelections
public boolean getMultipleSelections()
- Returns whether multiple selections are allowed.
- See Also:
- setMultipleSelections
setHorizontalSeparatorVisible
public synchronized 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
isHorizontalSeparatorVisible
public boolean isHorizontalSeparatorVisible()
- Returns whether horizontal separator lines are shown between
each listbox row.
- See Also:
- setHorizontalSeparatorVisible
setVerticalSeparatorVisible
public synchronized 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
isVerticalSeparatorVisible
public boolean isVerticalSeparatorVisible()
- Returns whether the vertical separators are being shown.
- See Also:
- setVerticalSeparatorVisible
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
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
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
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
setBorderVisible
public synchronized void setBorderVisible(boolean visible)
- Shows or hides the listbox border.
- Parameters:
- visible - True to show the border, false to hide.
- See Also:
- isBorderVisible
isBorderVisible
public boolean isBorderVisible()
- Returns true if the listbox border is showing, false otherwise.
- See Also:
- setBorderVisible
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
setCaptionBarBackgroundImage
public void setCaptionBarBackgroundImage(Image image)
- Sets the background image of the caption bar. 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
getCaptionBarBackgroundImage
public Image getCaptionBarBackgroundImage()
- Returns the current background image of the caption bar
or null if none is set.
- See Also:
- setBackgroundImage
getBackgroundImage
public Image getBackgroundImage()
- Returns the current background image or null if none
is set.
- See Also:
- setBackgroundImage
getColumnCount
public synchronized int getColumnCount()
- Returns the number of columns in the listbox.
- See Also:
- addColumn, getColumnInfo
getColumn
public synchronized Object[] getColumn(int col)
- Returns the array of values in the column, or null if
column specified is invalid.
- Parameters:
- col - The column to return.
- See Also:
- addColumn
autoSizeColumn
public synchronized void autoSizeColumn(int col)
- Resizes the specified column to fit the widest element
currently in the column.
- Parameters:
- col - The column to resize
addColumn
public synchronized ListboxColumn addColumn(Object 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
addColumns
public void addColumns(Object 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
removeColumn
public synchronized void removeColumn(int col)
- Removes a column from the listbox.
- Parameters:
- col - The index of the column to remove.
- See Also:
- removeAllColumns, addColumn
removeAllColumns
public synchronized void removeAllColumns()
- Removes all of the columns from the listbox.
- See Also:
- removeColumn
getColumnInfo
public synchronized ListboxColumn getColumnInfo(int column)
- Returns a reference to specified column or null if no
such column index exists.
- Parameters:
- column - The column to return.
replaceColumn
public synchronized 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, null values 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
makeRowVisible
public synchronized void makeRowVisible(int row)
- Makes the specified row index visible in the listbox.
getRowCount
public synchronized int getRowCount()
- Returns the number of rows in the listbox.
- See Also:
- getColumnCount
getRow
public synchronized Object[] getRow(int row)
- Returns the array of values in the row, or null if
row specified is invalid.
- Parameters:
- row - The row to return.
- See Also:
- addRow
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
addRow
public synchronized 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
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
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
removeRow
public synchronized void removeRow(int row)
- Removes a row from the listbox.
- Parameters:
- row - The row to remove.
- See Also:
- removeRows, getRow, addRow, replaceRow
removeAllRows
public synchronized void removeAllRows()
- Removes all of the rows from the listbox.
- See Also:
- removeRow
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
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
insertRow
public synchronized void insertRow(Object elements[],
Object key,
int row)
- Inserts a row of data into the listbox.
Note: Because the listbox data was moved into a separate
model Bean, insertRow may not work as you expect. If you are
using the listbox the same way as in previous versions, you
will not notice any change.
However, if you are working
with a model as your data source, then you have to be careful.
In this situation the listbox becomes a view of the data
in the model -- the listbox does not rearrange the physical
ordering of rows during a sort. This is done so that multiple
listboxes can share the same data source but the sort of one
listbox will not affect the other listboxes -- each listbox
retains its own sort "state". An insertRow in this scheme will
insert the row into the physical model at the row specified
but will be reflected in the listbox's view as an added row.
- Parameters:
- elements - The row of data to insert.
- key - The key for this row of data
- row - Which row to insert new row before.
insertRows
public void insertRows(Object rows[][],
int row)
- Inserts the given rows at the specified index with the
default key value.
- Parameters:
- rows - The rows to insert.
- row - The index where to insert.
- See Also:
- insertRow
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
replaceRow
public synchronized void replaceRow(Object elements[],
int row)
- Replaces all elements of the given row with the specified
elements. If the array of elements does not contain the same
number of elements for the number of columns in the listbox,
null values 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
getKeys
public synchronized 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
getRowByKey
public synchronized 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
getIndexByKey
public synchronized 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
setRowKey
public synchronized 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
getRowKey
public synchronized Object getRowKey(int row)
- Returns the key value for the specified row.
- Parameters:
- row - The row to return the key for.
- See Also:
- setRowKey
listboxColumnToTableColumn
public synchronized int listboxColumnToTableColumn(int col)
- Returns the physical table column associated with the specified
listbox column, or -1 if no mapping exists.
- Parameters:
- col - The listbox column.
- See Also:
- listboxRowToTableRow
listboxRowToTableRow
public synchronized int listboxRowToTableRow(int row)
- Returns the physical table row associated with the specified
listbox row, or -1 if no mapping exists.
- Parameters:
- row - The listbox row.
- See Also:
- listboxColumnToTableColumn
setSelectable
public synchronized void setSelectable(boolean selectable)
- Sets whether the user is allowed to select rows
in the listbox. The listbox is selectable by default.
- Parameters:
- selectable - True if selectable, false otherwise.
- See Also:
- isSelectable
isSelectable
public boolean isSelectable()
- Returns true if the listbox is selectable, false otherwise.
- See Also:
- setSelectable
selectColumn
public synchronized void selectColumn(int col)
- Selects the specified column.
- Parameters:
- col - The index of the column to select.
- See Also:
- ListboxColumn, addColumn, getColumn, replaceColumn
selectRow
public synchronized void selectRow(int row)
- Selects a row.
- Parameters:
- row - Which row to select.
- See Also:
- deselectRow, selectAllRows, selectRowByKey
invertSelections
public synchronized void invertSelections()
- Inverts the selected rows -- selected rows become deselected
and deselected rows become selected. This method only works
if multiple selection mode is set to true.
- See Also:
- setMultipleSelections
selectAllRows
public synchronized 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
selectRowByKey
public synchronized void selectRowByKey(Object key)
- Selects the first row with the specified key.
- Parameters:
- key - The key of the row to select.
- See Also:
- deselectRowByKey, selectRow, selectAllRows
deselectRow
public synchronized void deselectRow(int row)
- Deselects a row.
- Parameters:
- row - The row to deselect.
- See Also:
- deselectAllRows, deselectRowByKey, selectRow
deselectAllRows
public synchronized void deselectAllRows()
- Deselects all of the rows.
- See Also:
- deselectRow, deselectRowByKey, selectAllRows
deselectRowByKey
public synchronized void deselectRowByKey(Object key)
- Deselects the first row with the specified key.
- Parameters:
- key - The key of the row to deselect.
- See Also:
- deselectRow, deselectAllRows, selectRowByKey
getSelectedColumnIndex
public int getSelectedColumnIndex()
- Returns the index of the selected column.
getSelectedIndex
public synchronized int getSelectedIndex()
- Returns the index of the first selected row or -1 if
no row is selected.
- See Also:
- selectRow, deselectRow, getSelectedIndexes, getSelectedRow, getSelectedRows
getSelectedIndexes
public synchronized 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
getSelectedRow
public synchronized 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
getSelectedRows
public synchronized Object[][] getSelectedRows()
- Returns all of the selected rows as an array of rows.
- See Also:
- getSelectedRow
setVerticalScrollbarVisible
public void setVerticalScrollbarVisible(boolean visible)
- Note: setVerticalScrollbarVisible() is deprecated.
The scrollbars now show or hide automatically.
- Shows or hides the vertical scrollbar.
isVerticalScrollbarVisible
public boolean isVerticalScrollbarVisible()
- Note: isVerticalScrollbarVisible() is deprecated.
The scrollbars now show or hide automatically.
- Returns whether the vertical scrollbar is shown.
setHorizontalScrollbarVisible
public void setHorizontalScrollbarVisible(boolean visible)
- Note: setHorizontalScrollbarVisible() is deprecated.
The scrollbars now show or hide automatically.
- Shows or hides the horizontal scrollbar.
isHorizontalScrollbarVisible
public boolean isHorizontalScrollbarVisible()
- Note: isHorizontalScrollbarVisible() is deprecated.
The scrollbars now show or hide automatically.
- Returns whether the horizontal scrollbar is shown.
update
public void update(Graphics g)
- public void repaint() {
if (fUpdate) {
// repaint components
fCaptionBar.repaint();
fViewArea.repaint();
fHScrollbar.repaint();
fVScrollbar.repaint();
}
}
/**
Don't clear area -- not needed.
- Overrides:
- update in class Container
paint
public void paint(Graphics g)
- Handles painting of the border. The component pieces of the
listbox paint themselves.
- Overrides:
- paint in class Container
tableRefreshed
public synchronized void tableRefreshed(TableEvent evt)
- Table refreshed.
tableChanged
public void tableChanged(TableEvent evt)
- Table completely changed.
columnChanged
public void columnChanged(TableEvent evt)
- Column was changed.
rowChanged
public void rowChanged(TableEvent evt)
- Row was changed.
elementChanged
public void elementChanged(TableEvent evt)
- An element's data changed.
columnInfoChanged
public void columnInfoChanged(TableEvent evt)
- Column information changed.
columnAdded
public synchronized void columnAdded(TableEvent evt)
- A column was added.
columnRemoved
public synchronized void columnRemoved(TableEvent evt)
- A column was removed.
columnInserted
public void columnInserted(TableEvent evt)
- A column was inserted.
rowInfoChanged
public void rowInfoChanged(TableEvent evt)
- Row information changed.
rowAdded
public synchronized void rowAdded(TableEvent evt)
- A row was added.
rowRemoved
public synchronized void rowRemoved(TableEvent evt)
- A row was removed.
rowInserted
public synchronized void rowInserted(TableEvent evt)
- A row was inserted.
captionSelected
public synchronized void captionSelected(CaptionBarEvent evt)
- A caption was selected.
captionResized
public synchronized void captionResized(CaptionBarEvent evt)
- A caption was resized. If the click count on a caption
resize event is greater than 1, then the user is
requesting an auto sizing of the column. This request
can be ignored by the caption bar owner, however.
mouseClicked
public void mouseClicked(MouseEvent evt)
- A mouse button was clicked.
mousePressed
public void mousePressed(MouseEvent evt)
- A mouse button was pressed.
mouseReleased
public void mouseReleased(MouseEvent evt)
- A mouse button was released.
mouseEntered
public void mouseEntered(MouseEvent evt)
- The mouse cursor entered the component.
mouseExited
public void mouseExited(MouseEvent evt)
- The mouse cursor exited the component.
keyTyped
public void keyTyped(KeyEvent evt)
- A key was typed.
keyPressed
public void keyPressed(KeyEvent evt)
- A key was pressed.
keyReleased
public void keyReleased(KeyEvent evt)
- A key was released.
adjustmentValueChanged
public synchronized void adjustmentValueChanged(AdjustmentEvent evt)
- Adjustment value changed.
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.
allowSelection
protected boolean allowSelection(ListboxEvent event)
- This function acts as a mask to allow/disallow selection
given a specific row, column, and relative (x,y) within it.
The default is to always allow selection, but subclasses
can disallow it.
- Parameters:
- event - The event that will be passed to listeners
if the selection is allowed. This event
object can be queried for the event type,
row, col, and (x,y) coordinates of the
mouse click.
- Returns:
- Returns true if the selection is allowed, false
otherwise. The default return value is true.
deliverEvent
protected void deliverEvent(EventObject evt)
- This function delivers listbox related events. By overriding
this method in a subclass, you can modify outgoing listbox
events or even decide not to deliver certain events. The
default implementation of this method handles ListboxEvents
and ItemEvents.
- Parameters:
- event - The event to deliver.
createCaption
public ListboxCaption createCaption()
- This function is a "factory" method that creates a listbox
caption. By overriding this method in a subclass, you can
define a new look to a listbox caption.
toString
public String toString()
- Returns a text representation of this instance of MultiColumnListbox.
- Returns:
- Returns string representation of listbox.
- Overrides:
- toString in class Component
All Packages Class Hierarchy This Package Previous Next Index