Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Class java.awt.swing.table.DefaultTableColumnModel

java.lang.Object
    |
    +----java.awt.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

Field Summary
ChangeEvent  changeEvent
Change event (only one needed)
int  columnMargin
Width margin between each column
boolean  columnSelectionAllowed
Column selection allowed in this column model
EventListenerList  listenerList
List of TableColumnModelListener
ListSelectionModel  selectionModel
Model for keeping track of column selections
Vector  tableColumns
Array of TableColumn objects in this model
int  totalColumnWidth
A local cache of the combined width of all columns
 

Constructor Summary
 DefaultTableColumnModel()
 
 

Method Summary
void  addColumn(TableColumn aColumn)
Appends aColumn to the end of the receiver's tableColumns array.
void  addColumnModelListener(TableColumnModelListener x)
 
ListSelectionModel  createSelectionModel()
 
void  fireColumnAdded(TableColumnModelEvent e)
 
void  fireColumnMarginChanged()
 
void  fireColumnMoved(TableColumnModelEvent e)
 
void  fireColumnRemoved(TableColumnModelEvent e)
 
void  fireColumnSelectionChanged(ListSelectionEvent e)
 
TableColumn  getColumn(int columnIndex)
Returns the TableColumn object for the column at columnIndex
int  getColumnCount()
Returns the number of columns in the receiver's table columns array.
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().
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.
int  getColumnMargin()
Returns the width margin for TableColumn.
Enumeration  getColumns()
Returns an Enumeration of all the columns in the model
boolean  getColumnSelectionAllowed()
 
int  getSelectedColumnCount()
 
int[]  getSelectedColumns()
 
ListSelectionModel  getSelectionModel()
Returns the ListSelectionModel that is used to maintain column selection state.
int  getTotalColumnWidth()
 
void  moveColumn(int columnIndex, int newIndex)
Moves the column and heading at columnIndex to newIndex.
void  propertyChange(PropertyChangeEvent evt)
 
void  recalcWidthCache()
 
void  removeColumn(TableColumn column)
Deletes the TableColumn column from the receiver's table columns array.
void  removeColumnModelListener(TableColumnModelListener x)
 
void  setColumnMargin(int newMargin)
Sets the column margin to newMargin.
void  setColumnSelectionAllowed(boolean flag)
 
void  setSelectionModel(ListSelectionModel newModel)
Sets the selection model for this TableColumnModel to newModel and registers with for listner notifications from the new selection model.
void  valueChanged(ListSelectionEvent e)
 
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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
Constructor Detail

DefaultTableColumnModel

public DefaultTableColumnModel()
Method Detail

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.
Implements:
addColumn in interface TableColumnModel
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.
Implements:
removeColumn in interface TableColumnModel
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.
Implements:
moveColumn in interface TableColumnModel
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.
Implements:
setColumnMargin in interface TableColumnModel
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.
Implements:
getColumnCount in interface TableColumnModel
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
Implements:
getColumns in interface TableColumnModel

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().
Implements:
getColumnIndex in interface TableColumnModel
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
Implements:
getColumn in interface TableColumnModel
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.
Implements:
getColumnMargin in interface TableColumnModel
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.
Implements:
getColumnIndexAtX in interface TableColumnModel
Returns:
the index of the column or -1 if no column is found

getTotalColumnWidth

public int getTotalColumnWidth()
Implements:
getTotalColumnWidth in interface TableColumnModel

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.
Implements:
setSelectionModel in interface TableColumnModel
Parameters:
newModel - the new selection model
See Also:
getSelectionModel()

getSelectionModel

public ListSelectionModel getSelectionModel()
Returns the ListSelectionModel that is used to maintain column selection state.
Implements:
getSelectionModel in interface TableColumnModel
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)
Implements:
setColumnSelectionAllowed in interface TableColumnModel

getColumnSelectionAllowed

public boolean getColumnSelectionAllowed()
Implements:
getColumnSelectionAllowed in interface TableColumnModel

getSelectedColumns

public int[] getSelectedColumns()
Implements:
getSelectedColumns in interface TableColumnModel

getSelectedColumnCount

public int getSelectedColumnCount()
Implements:
getSelectedColumnCount in interface TableColumnModel

addColumnModelListener

public void addColumnModelListener(TableColumnModelListener x)
Implements:
addColumnModelListener in interface TableColumnModel

removeColumnModelListener

public void removeColumnModelListener(TableColumnModelListener x)
Implements:
removeColumnModelListener in interface TableColumnModel

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)
Implements:
propertyChange in interface PropertyChangeListener

valueChanged

public void valueChanged(ListSelectionEvent e)
Implements:
valueChanged in interface ListSelectionListener

createSelectionModel

protected ListSelectionModel createSelectionModel()

recalcWidthCache

protected void recalcWidthCache()

Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.