|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.table.DefaultTableColumnModel
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 applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
JTable
, Serialized FormField Summary | |
protected ChangeEvent |
changeEvent
Change event (only one needed) |
protected int |
columnMargin
Width margin between each column |
protected boolean |
columnSelectionAllowed
Column selection allowed in this column model |
protected EventListenerList |
listenerList
List of TableColumnModelListener |
protected ListSelectionModel |
selectionModel
Model for keeping track of column selections |
protected Vector |
tableColumns
Array of TableColumn objects in this model |
protected int |
totalColumnWidth
A local cache of the combined width of all columns |
Constructor Summary | |
DefaultTableColumnModel()
Creates a default table column model. |
Method Summary | |
void |
addColumn(TableColumn aColumn)
Appends aColumn to the end of the
tableColumns array. |
void |
addColumnModelListener(TableColumnModelListener x)
Adds a listener for table column model events. |
protected ListSelectionModel |
createSelectionModel()
Creates a new default list selection model. |
protected void |
fireColumnAdded(TableColumnModelEvent e)
Notifies all listeners that have registered interest for notification on this event type. |
protected void |
fireColumnMarginChanged()
Notifies all listeners that have registered interest for notification on this event type. |
protected void |
fireColumnMoved(TableColumnModelEvent e)
Notifies all listeners that have registered interest for notification on this event type. |
protected void |
fireColumnRemoved(TableColumnModelEvent e)
Notifies all listeners that have registered interest for notification on this event type. |
protected void |
fireColumnSelectionChanged(ListSelectionEvent e)
Notifies all listeners that have registered interest for notification on this event type. |
TableColumn |
getColumn(int columnIndex)
Returns the TableColumn object for the column
at columnIndex . |
int |
getColumnCount()
Returns the number of columns in the tableColumns array. |
int |
getColumnIndex(Object identifier)
Returns the index of the first column in the tableColumns
array whose identifier is equal to identifier ,
when compared using equals . |
int |
getColumnIndexAtX(int x)
Returns the index of the column that lies at position x ,
or -1 if no column covers this point. |
int |
getColumnMargin()
Returns the width margin for TableColumn . |
Enumeration |
getColumns()
Returns an Enumeration of all the columns in the model. |
boolean |
getColumnSelectionAllowed()
Returns true if column selection is allowed, otherwise false. |
EventListener[] |
getListeners(Class listenerType)
Returns an array of all the listeners of the given type that were added to this model. |
int |
getSelectedColumnCount()
Returns the number of columns selected. |
int[] |
getSelectedColumns()
Returns an array of selected columns. |
ListSelectionModel |
getSelectionModel()
Returns the ListSelectionModel that is used to
maintain column selection state. |
int |
getTotalColumnWidth()
Returns the total combined width of all columns. |
void |
moveColumn(int columnIndex,
int newIndex)
Moves the column and heading at columnIndex to
newIndex . |
void |
propertyChange(PropertyChangeEvent evt)
Property Change Listener change method. |
protected void |
recalcWidthCache()
Recalculates the total combined width of all columns. |
void |
removeColumn(TableColumn column)
Deletes the column from the
tableColumns array. |
void |
removeColumnModelListener(TableColumnModelListener x)
Removes a listener for table column model events. |
void |
setColumnMargin(int newMargin)
Sets the column margin to newMargin . |
void |
setColumnSelectionAllowed(boolean flag)
Sets whether column selection is allowed. |
void |
setSelectionModel(ListSelectionModel newModel)
Sets the selection model for this TableColumnModel
to newModel
and registers for listener notifications from the new selection
model. |
void |
valueChanged(ListSelectionEvent e)
A ListSelectionListener that forwards
ListSelectionEvents when there is a column
selection change. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Vector tableColumns
protected ListSelectionModel selectionModel
protected int columnMargin
protected EventListenerList listenerList
protected transient ChangeEvent changeEvent
protected boolean columnSelectionAllowed
protected int totalColumnWidth
Constructor Detail |
public DefaultTableColumnModel()
Method Detail |
public void addColumn(TableColumn aColumn)
aColumn
to the end of the
tableColumns
array.
This method also posts the columnAdded
event to its listeners.addColumn
in interface TableColumnModel
column
- the TableColumn
to be addedIllegalArgumentException
- if aColumn
is
null
removeColumn(javax.swing.table.TableColumn)
public void removeColumn(TableColumn column)
column
from the
tableColumns
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 a columnRemoved
event to its listeners.removeColumn
in interface TableColumnModel
column
- the TableColumn
to be removedaddColumn(javax.swing.table.TableColumn)
public void moveColumn(int columnIndex, int newIndex)
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 a columnMoved
event to its listeners.moveColumn
in interface TableColumnModel
columnIndex
- the index of column to be movednewIndex
- new index to move the columnIllegalArgumentException
- if column
or
newIndex
are not in the valid rangepublic void setColumnMargin(int newMargin)
newMargin
. This method
also posts a columnMarginChanged
event to its
listeners.setColumnMargin
in interface TableColumnModel
newMargin
- the new margin width, in pixelsgetColumnMargin()
,
getTotalColumnWidth()
public int getColumnCount()
tableColumns
array.getColumnCount
in interface TableColumnModel
tableColumns
arraygetColumns()
public Enumeration getColumns()
Enumeration
of all the columns in the model.getColumns
in interface TableColumnModel
Enumeration
of the columns in the modelpublic int getColumnIndex(Object identifier)
tableColumns
array whose identifier is equal to identifier
,
when compared using equals
.getColumnIndex
in interface TableColumnModel
identifier
- the identifier objecttableColumns
array whose identifier
is equal to identifier
IllegalArgumentException
- if identifier
is null
, or if no
TableColumn
has this
identifier
getColumn(int)
public TableColumn getColumn(int columnIndex)
TableColumn
object for the column
at columnIndex
.getColumn
in interface TableColumnModel
columnIndex
- the index of the column desiredTableColumn
object for the column
at columnIndex
public int getColumnMargin()
TableColumn
.
The default columnMargin
is 1.getColumnMargin
in interface TableColumnModel
TableColumn
setColumnMargin(int)
public int getColumnIndexAtX(int x)
x
,
or -1 if no column covers this point.getColumnIndexAtX
in interface TableColumnModel
x
- the horizontal location of interestpublic int getTotalColumnWidth()
getTotalColumnWidth
in interface TableColumnModel
totalColumnWidth
propertypublic void setSelectionModel(ListSelectionModel newModel)
TableColumnModel
to newModel
and registers for listener notifications from the new selection
model. If newModel
is null
,
an exception is thrown.setSelectionModel
in interface TableColumnModel
newModel
- the new selection modelIllegalArgumentException
- if newModel
is null
getSelectionModel()
public ListSelectionModel getSelectionModel()
ListSelectionModel
that is used to
maintain column selection state.getSelectionModel
in interface TableColumnModel
null
if row selection is not allowed.setSelectionModel(javax.swing.ListSelectionModel)
public void setColumnSelectionAllowed(boolean flag)
setColumnSelectionAllowed
in interface TableColumnModel
true
- if column selection will be allowed, false otherwisepublic boolean getColumnSelectionAllowed()
getColumnSelectionAllowed
in interface TableColumnModel
columnSelectionAllowed
propertypublic int[] getSelectedColumns()
selectionModel
is null
, returns an empty array.getSelectedColumns
in interface TableColumnModel
selectionModel
is
null
public int getSelectedColumnCount()
getSelectedColumnCount
in interface TableColumnModel
public void addColumnModelListener(TableColumnModelListener x)
addColumnModelListener
in interface TableColumnModel
x
- a TableColumnModelListener
objectpublic void removeColumnModelListener(TableColumnModelListener x)
removeColumnModelListener
in interface TableColumnModel
x
- a TableColumnModelListener
objectprotected void fireColumnAdded(TableColumnModelEvent e)
e
- the event receivedEventListenerList
protected void fireColumnRemoved(TableColumnModelEvent e)
e
- the event receivedEventListenerList
protected void fireColumnMoved(TableColumnModelEvent e)
e
- the event receivedEventListenerList
protected void fireColumnSelectionChanged(ListSelectionEvent e)
e
- the event receivedEventListenerList
protected void fireColumnMarginChanged()
e
- the event receivedEventListenerList
public EventListener[] getListeners(Class listenerType)
listenerType
- the listener class to matchlistenerType
notifications from this modelpublic void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
evt
- PropertyChangeEvent
public void valueChanged(ListSelectionEvent e)
ListSelectionListener
that forwards
ListSelectionEvents
when there is a column
selection change.valueChanged
in interface ListSelectionListener
e
- the change eventprotected ListSelectionModel createSelectionModel()
protected void recalcWidthCache()
totalColumnWidth
property.
|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.