All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jp.kyasu.awt.TableList

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----jp.kyasu.awt.KContainer
                           |
                           +----jp.kyasu.awt.EventProxyContainer
                                   |
                                   +----jp.kyasu.awt.TableList

public class TableList
extends EventProxyContainer
implements ItemSelectable, ActionListener, ItemListener
The TableList component presents the user with a scrolling table list that has multiple columns. The table list can be set up so that the user can choose either one row or multiple rows.

A TableList is an MVC-based component. The model of the TableList is a TextListModel object, the view of the TableList is a TextListView (TableListView) object, and the controller of the TableList is a TextListController object.

A TableList emits a ListActionEvent and a ListItemEvent.

Version:
12 Dec 1998
Author:
Kazuki YASUMATSU
See Also:
ListModel, TextListModel, TableListView, TextListView, TextListController, ListActionEvent, ListItemEvent

Variable Index

 o AUTO_RESIZE_ALL_COLUMNS
Proportionately resize all columns when table is resized
 o AUTO_RESIZE_LAST_COLUMN
Auto resize last column only when table is resized
 o AUTO_RESIZE_OFF
Do not auto resize column when table is resized.
 o DEFAULT_BUTTON_ALIGN
The default column button alignment.
 o DEFAULT_TABLE_STYLE
The default table list style.
 o MULTIPLE_SELECTIONS
Allows AWT style multiple selections.
 o SHIFT_MULTIPLE_SELECTIONS
Allows Windows style multiple selections.
 o SINGLE_SELECTION
Allows single selection.

Constructor Index

 o TableList(int, String[])
Constructs an empty table list with the specified number of visual lines and column titles.
 o TableList(int, String[], int[])
Constructs an empty table list with the specified number of visual lines, column titles, and widths of the columns.
 o TableList(int, String[], int[], int[], RichTextStyle)
Constructs an empty table list with the specified column titles, alignments of the column titles, widths of the columns, and the rich text style of the table list.
 o TableList(int, String[], int[], RichTextStyle)
Constructs an empty table list with the specified column titles, widths of the columns, and the rich text style of the table list.
 o TableList(String[])
Constructs an empty table list with the specified column titles.
 o TableList(TextListModel, int, Button[])
Constructs a table list with the specified model, number of visual lines, and column buttons.
 o TableList(TextListModel, int, String[])
Constructs a table list with the specified model, number of visual lines, and column titles.
 o TableList(TextListModel, int, String[], int[])
Constructs a table list with the specified model, number of visual lines, column titles, and alignments of the column titles.

Method Index

 o actionPerformed(ActionEvent)
Invoked when an action occurs.
 o addActionListener(ActionListener)
Adds the specified action listener to receive action events from this list.
 o addItem(String[])
Adds the specified string row item to the end of the table list.
 o addItem(String[], int)
Adds the specified string row item to the specified row index.
 o addItem(Text[])
Adds the specified text row item to the end of the table list.
 o addItem(Text[], int)
Adds the specified text row item to the specified row index.
 o addItemListener(ItemListener)
Adds the specified item listener to receive item events from this list.
 o addTextItem(Text[])
Adds the specified text row item to the end of the table list.
 o addTextItem(Text[], int)
Adds the specified text row item to the specified row index.
 o deselect(int)
Deselects the row at the specified index.
 o getAutoResizeMode()
Returns the auto resize mode of the panel.
 o getColumnButtons()
Returns the buttons for the column titles.
 o getColumnCount()
Returns the number of columns in the list.
 o getColumnTitles()
Returns the column titles.
 o getController()
Returns the controller of this list.
 o getItem(int, int)
Returns the string item associated with the specified index (row) and column.
 o getItemCount()
Returns the number of items in the list.
 o getItems(int)
Returns the string items associated with the specified column index.
 o getMinimumSize()
Returns the minimum size of this table list.
 o getMinimumSize(int)
Returns the minumum dimensions for a table list with the specified number of visual lines.
 o getModel()
Returns the model of this list.
 o getPopupMenu()
Returns the popup menu of this list.
 o getPreferredSize()
Returns the preferred size of this table list.
 o getPreferredSize(int)
Returns the preferred dimensions for a table list with the specified number of visual lines.
 o getRowItem(int)
Returns the item associated with the specified row index.
 o getRowItems(int)
Returns the string items associated with the specified row index.
 o getRows()
Get the number of visible lines in this table list.
 o getRowTextItem(int)
Returns the text item associated with the specified row index.
 o getRowTextItems(int)
Returns the text items associated with the specified row index.
 o getScrollbarThickness()
Returns the thickness of the scroll bar.
 o getSelectedIndex()
Gets the index of the selected row on the list,
 o getSelectedIndexes()
Gets the selected row indexes on the list.
 o getSelectedObjects()
Returns the selected items on the list in an array of Objects.
 o getSelectionBackground()
Returns the selection background color.
 o getSelectionForeground()
Returns the selection foreground color.
 o getSelectionMode()
Returns the selection mode.
 o getTextItem(int, int)
Returns the text item associated with the specified index (row) and column.
 o getTextItems(int)
Returns the text items associated with the specified column index.
 o getView()
Returns the view of this list.
 o getVisibleIndex()
Gets the index of the row that was last made visible by the method makeVisible.
 o isClickToFocus()
Tests if the list requests the focus when the mouse is clicked.
 o isDeselectionEnabled()
Tests if the deselection is enabled when the selection mode is a single selection.
 o isIndexSelected(int)
Determines if the specified row in this scrolling list is selected.
 o isMouseFocus()
Tests if the list requests the focus when the mouse enters the list.
 o isMultipleMode()
Determines whether this list allows multiple selections.
 o itemStateChanged(ItemEvent)
Invoked when an item's state has been changed.
 o makeVisible(int)
Makes the row at the specified index visible.
 o remove(int)
Remove the item at the specified row position.
 o remove(int, int)
Remove the items at the specified row range.
 o remove(int[])
Remove the items at the specified row indices.
 o removeActionListener(ActionListener)
Removes the specified action listener so that it no longer receives action events from this list.
 o removeAll()
Removes all items from the list.
 o removeItemListener(ItemListener)
Removes the specified item listener so that it no longer receives item events from this list.
 o removeSelectedIndexes()
Remove the items at the indices of the selected rows.
 o replaceItem(String[], int)
Replaces the item at the specified row index with the new strings.
 o replaceItem(Text[], int)
Replaces the item at the specified row index with the new texts.
 o replaceTextItem(Text[], int)
Replaces the item at the specified row index with the new texts.
 o select(int)
Selects the row at the specified index in the scrolling list.
 o setAutoResizeMode(int)
Sets the the auto resize mode of the panel.
 o setBackground(Color)
Sets the background color of this list.
 o setClickToFocus()
Makes the list request the focus when the mouse is clicked.
 o setCursor(Cursor)
Sets the cursor of this list.
 o setDeselectionEnabled(boolean)
Makes the deselection enabled when the selection mode is a single selection.
 o setEnabled(boolean)
Enables or disables this list.
 o setFont(Font)
Sets the font of this list.
 o setForeground(Color)
Sets the foreground color of this list.
 o setItem(int, int, String)
Sets the item associated with the specified index (row) and column to the specified string value.
 o setItem(int, int, Text)
Sets the item associated with the specified index (row) and column to the specified text value.
 o setItems(String[][])
Sets the items of the list to the specified string row by column items.
 o setItems(Text[][])
Sets the items of the list to the specified text row by column items.
 o setMouseFocus()
Makes the list request the focus when the mouse enters the list.
 o setMultipleMode(boolean)
Sets the flag that determines whether this list allows multiple selections.
 o setPopupMenu(PopupMenu)
Sets the popup menu of this list.
 o setRows(int)
Sets the number of visible lines in this table list.
 o setScrollbarThickness(int)
Sets the thickness of the scroll bar.
 o setSelectionBackground(Color)
Sets the selection background color.
 o setSelectionForeground(Color)
Sets the selection foreground color.
 o setSelectionMode(int)
Sets the selection mode.
 o setTextItem(int, int, Text)
Sets the item associated with the specified index (row) and column to the specified text value.
 o setTextItems(Text[][])
Sets the items of the list to the specified text row by column items.

Variables

 o SINGLE_SELECTION
 public static final int SINGLE_SELECTION
Allows single selection.

 o MULTIPLE_SELECTIONS
 public static final int MULTIPLE_SELECTIONS
Allows AWT style multiple selections.

 o SHIFT_MULTIPLE_SELECTIONS
 public static final int SHIFT_MULTIPLE_SELECTIONS
Allows Windows style multiple selections.

 o AUTO_RESIZE_OFF
 public static final int AUTO_RESIZE_OFF
Do not auto resize column when table is resized.

 o AUTO_RESIZE_LAST_COLUMN
 public static final int AUTO_RESIZE_LAST_COLUMN
Auto resize last column only when table is resized

 o AUTO_RESIZE_ALL_COLUMNS
 public static final int AUTO_RESIZE_ALL_COLUMNS
Proportionately resize all columns when table is resized

 o DEFAULT_TABLE_STYLE
 public static final RichTextStyle DEFAULT_TABLE_STYLE
The default table list style.

 o DEFAULT_BUTTON_ALIGN
 public static final int DEFAULT_BUTTON_ALIGN
The default column button alignment.

Constructors

 o TableList
 public TableList(String columnTitles[])
Constructs an empty table list with the specified column titles.

Parameters:
columnTitles - the column titles.
 o TableList
 public TableList(int rows,
                  String columnTitles[])
Constructs an empty table list with the specified number of visual lines and column titles.

Parameters:
rows - the number of visual lines in the table list.
columnTitles - the column titles.
 o TableList
 public TableList(int rows,
                  String columnTitles[],
                  int columnWidths[])
Constructs an empty table list with the specified number of visual lines, column titles, and widths of the columns.

Parameters:
rows - the number of visual lines in the table list.
columnTitles - the column titles.
columnWidths - the widths of the columns, or null.
See Also:
LEFT, CENTER, RIGHT
 o TableList
 public TableList(int rows,
                  String columnTitles[],
                  int columnWidths[],
                  RichTextStyle richTextStyle)
Constructs an empty table list with the specified column titles, widths of the columns, and the rich text style of the table list.

Parameters:
rows - the number of visual lines in the table list.
columnTitles - the column titles.
columnWidths - the widths of the columns, or null.
richTextStyle - the rich text style of the table list.
See Also:
LEFT, CENTER, RIGHT
 o TableList
 public TableList(int rows,
                  String columnTitles[],
                  int columnAligns[],
                  int columnWidths[],
                  RichTextStyle richTextStyle)
Constructs an empty table list with the specified column titles, alignments of the column titles, widths of the columns, and the rich text style of the table list.

Parameters:
rows - the number of visual lines in the table list.
columnTitles - the column titles.
columnAligns - the alignments of the column titles, or null.
columnWidths - the widths of the columns, or null.
richTextStyle - the rich text style of the table list.
See Also:
LEFT, CENTER, RIGHT
 o TableList
 public TableList(TextListModel model,
                  int rows,
                  String columnTitles[])
Constructs a table list with the specified model, number of visual lines, and column titles.

Parameters:
model - the text list model.
rows - the number of visual lines in the table list.
columnTitles - the column titles.
 o TableList
 public TableList(TextListModel model,
                  int rows,
                  String columnTitles[],
                  int columnAligns[])
Constructs a table list with the specified model, number of visual lines, column titles, and alignments of the column titles.

Parameters:
model - the text list model.
rows - the number of visual lines in the table list.
columnTitles - the column titles.
columnAligns - the alignments of the column titles, or null.
See Also:
LEFT, CENTER, RIGHT
 o TableList
 public TableList(TextListModel model,
                  int rows,
                  Button buttons[])
Constructs a table list with the specified model, number of visual lines, and column buttons.

Parameters:
model - the text list model.
rows - the number of visual lines in the table list.
buttons - the buttons for column titles.

Methods

 o addItemListener
 public synchronized void addItemListener(ItemListener l)
Adds the specified item listener to receive item events from this list.

Parameters:
l - the item listener.
 o removeItemListener
 public synchronized void removeItemListener(ItemListener l)
Removes the specified item listener so that it no longer receives item events from this list.

Parameters:
l - the item listener.
 o addActionListener
 public synchronized void addActionListener(ActionListener l)
Adds the specified action listener to receive action events from this list. Action events occur when a user double-clicks on a list item.

Parameters:
l - the action listener.
 o removeActionListener
 public synchronized void removeActionListener(ActionListener l)
Removes the specified action listener so that it no longer receives action events from this list. Action events occur when a user double-clicks on a list item.

Parameters:
l - the action listener.
 o itemStateChanged
 public void itemStateChanged(ItemEvent e)
Invoked when an item's state has been changed.

See Also:
ItemListener
 o actionPerformed
 public void actionPerformed(ActionEvent e)
Invoked when an action occurs.

See Also:
ActionListener
 o setForeground
 public synchronized void setForeground(Color c)
Sets the foreground color of this list.

Overrides:
setForeground in class Component
 o setBackground
 public synchronized void setBackground(Color c)
Sets the background color of this list.

Overrides:
setBackground in class Component
 o setFont
 public synchronized void setFont(Font f)
Sets the font of this list.

Overrides:
setFont in class Component
 o setCursor
 public synchronized void setCursor(Cursor c)
Sets the cursor of this list.

Overrides:
setCursor in class Component
 o setEnabled
 public synchronized void setEnabled(boolean b)
Enables or disables this list.

Overrides:
setEnabled in class KContainer
 o getPreferredSize
 public Dimension getPreferredSize(int rows)
Returns the preferred dimensions for a table list with the specified number of visual lines.

Parameters:
rows - number of visual lines in the table list.
Returns:
the preferred dimensions for displaying this table list.
 o getPreferredSize
 public Dimension getPreferredSize()
Returns the preferred size of this table list.

Returns:
the preferred dimensions for displaying this table list.
Overrides:
getPreferredSize in class KContainer
 o getMinimumSize
 public Dimension getMinimumSize(int rows)
Returns the minumum dimensions for a table list with the specified number of visual lines.

Parameters:
rows - number of visual lines in the table list.
Returns:
the minimum dimensions for displaying this table list.
 o getMinimumSize
 public Dimension getMinimumSize()
Returns the minimum size of this table list.

Returns:
the minimum dimensions needed to display this table list.
Overrides:
getMinimumSize in class KContainer
 o getAutoResizeMode
 public int getAutoResizeMode()
Returns the auto resize mode of the panel. The default is AUTO_RESIZE_ALL_COLUMNS.

Returns:
the auto resize mode of the table.
See Also:
setAutoResizeMode
 o setAutoResizeMode
 public void setAutoResizeMode(int mode)
Sets the the auto resize mode of the panel.

Parameters:
mode - the auto resize mode.
See Also:
getAutoResizeMode, AUTO_RESIZE_OFF, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_ALL_COLUMNS
 o getRows
 public int getRows()
Get the number of visible lines in this table list.

Returns:
the number of visible lines in this table list.
See Also:
setRows
 o setRows
 public void setRows(int rows)
Sets the number of visible lines in this table list.

Parameters:
rows - the number of visible lines in this table list.
See Also:
getRows
 o getSelectedObjects
 public Object[] getSelectedObjects()
Returns the selected items on the list in an array of Objects.

See Also:
ItemSelectable
 o getModel
 public TextListModel getModel()
Returns the model of this list.

 o getView
 public TextListView getView()
Returns the view of this list.

 o getController
 public TextListController getController()
Returns the controller of this list.

 o getColumnButtons
 public synchronized Button[] getColumnButtons()
Returns the buttons for the column titles.

 o getColumnTitles
 public synchronized String[] getColumnTitles()
Returns the column titles.

 o getSelectionForeground
 public Color getSelectionForeground()
Returns the selection foreground color.

See Also:
setSelectionForeground
 o setSelectionForeground
 public synchronized void setSelectionForeground(Color c)
Sets the selection foreground color.

See Also:
getSelectionForeground
 o getSelectionBackground
 public Color getSelectionBackground()
Returns the selection background color.

See Also:
setSelectionBackground
 o setSelectionBackground
 public synchronized void setSelectionBackground(Color c)
Sets the selection background color.

See Also:
getSelectionBackground
 o getPopupMenu
 public PopupMenu getPopupMenu()
Returns the popup menu of this list.

See Also:
setPopupMenu
 o setPopupMenu
 public synchronized void setPopupMenu(PopupMenu menu)
Sets the popup menu of this list.

See Also:
getPopupMenu
 o isClickToFocus
 public boolean isClickToFocus()
Tests if the list requests the focus when the mouse is clicked.

Returns:
true if the list requests the focus when the mouse is clicked, false if the list requests the focus when the mouse enters the view.
See Also:
isMouseFocus
 o isMouseFocus
 public boolean isMouseFocus()
Tests if the list requests the focus when the mouse enters the list.

See Also:
isClickToFocus
 o setClickToFocus
 public void setClickToFocus()
Makes the list request the focus when the mouse is clicked.

See Also:
isClickToFocus, setMouseFocus
 o setMouseFocus
 public void setMouseFocus()
Makes the list request the focus when the mouse enters the list.

See Also:
isMouseFocus, setClickToFocus
 o isDeselectionEnabled
 public boolean isDeselectionEnabled()
Tests if the deselection is enabled when the selection mode is a single selection.

See Also:
setDeselectionEnabled
 o setDeselectionEnabled
 public synchronized void setDeselectionEnabled(boolean b)
Makes the deselection enabled when the selection mode is a single selection.

See Also:
isDeselectionEnabled
 o getSelectionMode
 public int getSelectionMode()
Returns the selection mode.

See Also:
setSelectionMode, SINGLE_SELECTION, MULTIPLE_SELECTIONS, SHIFT_MULTIPLE_SELECTIONS
 o setSelectionMode
 public synchronized void setSelectionMode(int mode)
Sets the selection mode.

See Also:
getSelectionMode, SINGLE_SELECTION, MULTIPLE_SELECTIONS, SHIFT_MULTIPLE_SELECTIONS
 o isMultipleMode
 public boolean isMultipleMode()
Determines whether this list allows multiple selections.

Returns:
true if this list allows multiple selections; false otherwise.
See Also:
setMultipleMode, getSelectionMode, setSelectionMode
 o setMultipleMode
 public synchronized void setMultipleMode(boolean b)
Sets the flag that determines whether this list allows multiple selections.

Parameters:
b - if true then multiple selections are allowed; otherwise, only one item from the list can be selected at once.
See Also:
isMultipleMode, getSelectionMode, setSelectionMode
 o getItemCount
 public int getItemCount()
Returns the number of items in the list.

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

 o getItem
 public String getItem(int index,
                       int column)
Returns the string item associated with the specified index (row) and column.

 o getTextItem
 public Text getTextItem(int index,
                         int column)
Returns the text item associated with the specified index (row) and column.

 o setItem
 public synchronized void setItem(int index,
                                  int column,
                                  String item)
Sets the item associated with the specified index (row) and column to the specified string value.

 o setItem
 public void setItem(int index,
                     int column,
                     Text item)
Sets the item associated with the specified index (row) and column to the specified text value.

 o setTextItem
 public synchronized void setTextItem(int index,
                                      int column,
                                      Text item)
Sets the item associated with the specified index (row) and column to the specified text value.

 o setItems
 public synchronized void setItems(String items[][])
Sets the items of the list to the specified string row by column items.

 o setItems
 public void setItems(Text items[][])
Sets the items of the list to the specified text row by column items.

 o setTextItems
 public synchronized void setTextItems(Text items[][])
Sets the items of the list to the specified text row by column items.

 o getRowItems
 public synchronized String[] getRowItems(int index)
Returns the string items associated with the specified row index.

 o getRowTextItems
 public Text[] getRowTextItems(int index)
Returns the text items associated with the specified row index.

 o getRowItem
 public synchronized String getRowItem(int index)
Returns the item associated with the specified row index.

 o getRowTextItem
 public synchronized Text getRowTextItem(int index)
Returns the text item associated with the specified row index.

 o getItems
 public synchronized String[] getItems(int column)
Returns the string items associated with the specified column index.

 o getTextItems
 public Text[] getTextItems(int column)
Returns the text items associated with the specified column index.

 o addItem
 public void addItem(String item[])
Adds the specified string row item to the end of the table list.

 o addItem
 public synchronized void addItem(String item[],
                                  int index)
Adds the specified string row item to the specified row index.

 o addItem
 public void addItem(Text item[])
Adds the specified text row item to the end of the table list.

 o addItem
 public void addItem(Text item[],
                     int index)
Adds the specified text row item to the specified row index.

 o addTextItem
 public void addTextItem(Text item[])
Adds the specified text row item to the end of the table list.

 o addTextItem
 public synchronized void addTextItem(Text item[],
                                      int index)
Adds the specified text row item to the specified row index.

 o replaceItem
 public synchronized void replaceItem(String newValue[],
                                      int index)
Replaces the item at the specified row index with the new strings.

 o replaceItem
 public void replaceItem(Text newValue[],
                         int index)
Replaces the item at the specified row index with the new texts.

 o replaceTextItem
 public synchronized void replaceTextItem(Text newValue[],
                                          int index)
Replaces the item at the specified row index with the new texts.

 o removeAll
 public synchronized void removeAll()
Removes all items from the list.

Overrides:
removeAll in class Container
 o remove
 public void remove(int position)
Remove the item at the specified row position.

Overrides:
remove in class Container
 o remove
 public synchronized void remove(int start,
                                 int end)
Remove the items at the specified row range.

Parameters:
start - the starting row position, inclusive.
end - the ending row position, inclusive.
 o remove
 public synchronized void remove(int indices[])
Remove the items at the specified row indices.

Parameters:
indices - the row indices to be removed.
 o removeSelectedIndexes
 public synchronized void removeSelectedIndexes()
Remove the items at the indices of the selected rows.

 o isIndexSelected
 public boolean isIndexSelected(int index)
Determines if the specified row in this scrolling list is selected.

Parameters:
index - the row to be checked.
Returns:
true if the specified row has been selected; false otherwise.
 o getSelectedIndex
 public synchronized int getSelectedIndex()
Gets the index of the selected row on the list,

Returns:
the index of the selected row, or -1 if no item is selected, or if more that one row is selected.
 o getSelectedIndexes
 public synchronized int[] getSelectedIndexes()
Gets the selected row indexes on the list.

Returns:
an array of the selected row indexes of this scrolling list.
 o select
 public synchronized void select(int index)
Selects the row at the specified index in the scrolling list.

Parameters:
index - the position of the row to select.
 o deselect
 public synchronized void deselect(int index)
Deselects the row at the specified index.

If the row at the specified index is not selected, or if the index is out of range, then the operation is ignored.

Parameters:
index - the position of the row to deselect.
 o getVisibleIndex
 public int getVisibleIndex()
Gets the index of the row that was last made visible by the method makeVisible.

Returns:
the index of the row that was last made visible.
See Also:
makeVisible
 o makeVisible
 public synchronized void makeVisible(int index)
Makes the row at the specified index visible.

Parameters:
index - the position of the row.
See Also:
getVisibleIndex
 o getScrollbarThickness
 public int getScrollbarThickness()
Returns the thickness of the scroll bar.

See Also:
setScrollbarThickness
 o setScrollbarThickness
 public synchronized void setScrollbarThickness(int thickness)
Sets the thickness of the scroll bar.

See Also:
setScrollbarThickness

All Packages  Class Hierarchy  This Package  Previous  Next  Index