Class com.sun.java.swing.table.DefaultTableColumnModel
java.lang.Object
|
+----com.sun.java.swing.table.DefaultTableColumnModel
- public class DefaultTableColumnModel
- extends Object
- implements TableColumnModel, PropertyChangeListener, ListSelectionListener, Serializable
The standard column-handler for a JTable.
Warning: serialized objects of this class will not be compatible with
future swing releases. The current serialization support is appropriate
for short term storage or RMI between Swing1.0 applications. It will
not be possible to load serialized Swing1.0 objects with future releases
of Swing. The JDK1.2 release of Swing will be the compatibility
baseline for the serialized form of Swing objects.
- See Also:
- JTable
Variable Index
- changeEvent
- Change event (only one needed)
- columnMargin
- Width margin between each column
- columnSelectionAllowed
- Column selection allowed in this column model
- listenerList
- List of TableColumnModelListener
- selectionModel
- Model for keeping track of column selections
- tableColumns
- Array of TableColumn objects in this model
- totalColumnWidth
- A local cache of the combined width of all columns
Constructor Index
- DefaultTableColumnModel()
-
Method Index
- addColumn(TableColumn)
- Appends aColumn to the end of the receiver's tableColumns array.
- addColumnModelListener(TableColumnModelListener)
-
- createSelectionModel()
-
- fireColumnAdded(TableColumnModelEvent)
-
- fireColumnMarginChanged()
-
- fireColumnMoved(TableColumnModelEvent)
-
- fireColumnRemoved(TableColumnModelEvent)
-
- fireColumnSelectionChanged(ListSelectionEvent)
-
- getColumn(int)
- Returns the TableColumn object for the column at columnIndex
- getColumnCount()
- Returns the number of columns in the receiver's table columns array.
- getColumnIndex(Object)
- Returns the index of the first column in the receiver's
columns array whose identifier is equal to identifier,
when compared using equals().
- getColumnIndexAtX(int)
- Returns the index of the column that lies on the xPosition,
or -1 if it lies outside the any of the column's bounds.
- getColumnMargin()
- Returns the width margin for TableColumn.
- getColumns()
- Returns an Enumeration of all the columns in the model
- getColumnSelectionAllowed()
-
- getSelectedColumnCount()
-
- getSelectedColumns()
-
- getSelectionModel()
- Returns the ListSelectionModel that is used to maintain column
selection state.
- getTotalColumnWidth()
-
- moveColumn(int, int)
- Moves the column and heading at columnIndex to newIndex.
- propertyChange(PropertyChangeEvent)
-
- recalcWidthCache()
-
- removeColumn(TableColumn)
- Deletes the TableColumn column from the
receiver's table columns array.
- removeColumnModelListener(TableColumnModelListener)
-
- setColumnMargin(int)
- Sets the column margin to newMargin.
- setColumnSelectionAllowed(boolean)
-
- setSelectionModel(ListSelectionModel)
- Sets the selection model for this TableColumnModel to newModel
and registers with for listner notifications from the new selection
model.
- valueChanged(ListSelectionEvent)
-
Variables
tableColumns
protected Vector tableColumns
- Array of TableColumn objects in this model
selectionModel
protected ListSelectionModel selectionModel
- Model for keeping track of column selections
columnMargin
protected int columnMargin
- Width margin between each column
listenerList
protected EventListenerList listenerList
- List of TableColumnModelListener
changeEvent
protected transient ChangeEvent changeEvent
- Change event (only one needed)
columnSelectionAllowed
protected boolean columnSelectionAllowed
- Column selection allowed in this column model
totalColumnWidth
protected int totalColumnWidth
- A local cache of the combined width of all columns
Constructors
DefaultTableColumnModel
public DefaultTableColumnModel()
Methods
addColumn
public void addColumn(TableColumn aColumn)
- Appends aColumn to the end of the receiver's tableColumns array.
This method also posts the columnAdded() event to its listeners.
- Parameters:
- column - The TableColumn to be added
- Throws: IllegalArgumentException
- if aColumn is null
- See Also:
- removeColumn
removeColumn
public void removeColumn(TableColumn column)
- Deletes the TableColumn column from the
receiver's table columns array. This method will do nothing if
column is not in the table's columns list. tile() is called
to resize both the header and table views.
This method also posts the columnRemoved() event to its listeners.
- Parameters:
- column - The TableColumn to be removed
- See Also:
- addColumn
moveColumn
public void moveColumn(int columnIndex,
int newIndex)
- Moves the column and heading at columnIndex to newIndex.
The old column at columnIndex will now be found at newIndex,
The column that used to be at newIndex is shifted left or right
to make room.
This will not move any columns if columnIndex equals newIndex.
This method also posts the columnMoved() event to its listeners.
- Parameters:
- columnIndex - the index of column to be moved
- newIndex - New index to move the column
- Throws: IllegalArgumentException
- if column or
newIndex
are not in the valid range
setColumnMargin
public void setColumnMargin(int newMargin)
- Sets the column margin to newMargin.
This method also posts the columnMarginChanged() event to its
listeners.
- Parameters:
- newMargin - the width margin of the column
- See Also:
- getColumnMargin, getTotalColumnWidth
getColumnCount
public int getColumnCount()
- Returns the number of columns in the receiver's table columns array.
- Returns:
- the number of columns in the receiver's table columns array
- See Also:
- getColumns
getColumns
public Enumeration getColumns()
- Returns an Enumeration of all the columns in the model
getColumnIndex
public int getColumnIndex(Object identifier)
- Returns the index of the first column in the receiver's
columns array whose identifier is equal to identifier,
when compared using equals().
- Parameters:
- identifier - the identifier object
- Returns:
- the index of the first table column in the receiver's
tableColumns array whose identifier is equal to
identifier, when compared using equals().
- Throws: IllegalArgumentException
- if identifier is null or no TableColumn has this identifier
- See Also:
- getColumn
getColumn
public TableColumn getColumn(int columnIndex)
- Returns the TableColumn object for the column at columnIndex
- Parameters:
- columnIndex - the index of the column desired
- Returns:
- the TableColumn object for the column at columnIndex
getColumnMargin
public int getColumnMargin()
- Returns the width margin for TableColumn.
The default columnMargin is 2.
- Returns:
- the maximum width for the TableColumn.
- See Also:
- setColumnMargin
getColumnIndexAtX
public int getColumnIndexAtX(int xPosition)
- Returns the index of the column that lies on the xPosition,
or -1 if it lies outside the any of the column's bounds.
- Returns:
- the index of the column or -1 if no column is found
getTotalColumnWidth
public int getTotalColumnWidth()
setSelectionModel
public void setSelectionModel(ListSelectionModel newModel)
- Sets the selection model for this TableColumnModel to newModel
and registers with for listner notifications from the new selection
model. If newModel is null, it means columns are not
selectable.
- Parameters:
- newModel - the new selection model
- See Also:
- getSelectionModel
getSelectionModel
public ListSelectionModel getSelectionModel()
- Returns the ListSelectionModel that is used to maintain column
selection state.
- Returns:
- the object that provides column selection state. Or
null if row selection is not allowed.
- See Also:
- setSelectionModel
setColumnSelectionAllowed
public void setColumnSelectionAllowed(boolean flag)
getColumnSelectionAllowed
public boolean getColumnSelectionAllowed()
getSelectedColumns
public int[] getSelectedColumns()
getSelectedColumnCount
public int getSelectedColumnCount()
addColumnModelListener
public void addColumnModelListener(TableColumnModelListener x)
removeColumnModelListener
public void removeColumnModelListener(TableColumnModelListener x)
fireColumnAdded
protected void fireColumnAdded(TableColumnModelEvent e)
fireColumnRemoved
protected void fireColumnRemoved(TableColumnModelEvent e)
fireColumnMoved
protected void fireColumnMoved(TableColumnModelEvent e)
fireColumnSelectionChanged
protected void fireColumnSelectionChanged(ListSelectionEvent e)
fireColumnMarginChanged
protected void fireColumnMarginChanged()
propertyChange
public void propertyChange(PropertyChangeEvent evt)
valueChanged
public void valueChanged(ListSelectionEvent e)
createSelectionModel
protected ListSelectionModel createSelectionModel()
recalcWidthCache
protected void recalcWidthCache()
