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. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans
package.
Please see XMLEncoder
.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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 |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a default table column model.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Appends
aColumn to the end of the
tableColumns array. | |||||||||||
Adds a listener for table column model events.
| |||||||||||
Returns the
TableColumn object for the column
at columnIndex . | |||||||||||
Returns the number of columns in the
tableColumns array. | |||||||||||
Returns the index of the first column in the
tableColumns
array whose identifier is equal to identifier ,
when compared using equals . | |||||||||||
Returns the index of the column that lies at position
x ,
or -1 if no column covers this point. | |||||||||||
Returns the width margin for
TableColumn . | |||||||||||
Returns an array of all the column model listeners
registered on this model.
| |||||||||||
Returns true if column selection is allowed, otherwise false.
| |||||||||||
Returns an
Enumeration of all the columns in the model. | |||||||||||
Returns an array of all the objects currently registered
as
FooListener s
upon this model. | |||||||||||
Returns the number of columns selected.
| |||||||||||
Returns an array of selected columns.
| |||||||||||
Returns the
ListSelectionModel that is used to
maintain column selection state. | |||||||||||
Returns the total combined width of all columns.
| |||||||||||
Moves the column and heading at
columnIndex to
newIndex . | |||||||||||
Property Change Listener change method.
| |||||||||||
Deletes the
column from the
tableColumns array. | |||||||||||
Removes a listener for table column model events.
| |||||||||||
Sets the column margin to
newMargin . | |||||||||||
Sets whether column selection is allowed.
| |||||||||||
Sets the selection model for this
TableColumnModel
to newModel
and registers for listener notifications from the new selection
model. | |||||||||||
A
ListSelectionListener that forwards
ListSelectionEvents when there is a column
selection change. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new default list selection model.
| |||||||||||
Notifies all listeners that have registered interest for
notification on this event type.
| |||||||||||
Notifies all listeners that have registered interest for
notification on this event type.
| |||||||||||
Notifies all listeners that have registered interest for
notification on this event type.
| |||||||||||
Notifies all listeners that have registered interest for
notification on this event type.
| |||||||||||
Notifies all listeners that have registered interest for
notification on this event type.
| |||||||||||
Recalculates the total combined width of all columns.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Width margin between each column
Column selection allowed in this column model
A local cache of the combined width of all columns
Creates a default table column model.
Appends aColumn
to the end of the
tableColumns
array.
This method also posts the columnAdded
event to its listeners.
aColumn | the TableColumn to be added |
---|
IllegalArgumentException | if aColumn is
null |
---|
Adds a listener for table column model events.
x | a TableColumnModelListener object
|
---|
Returns the TableColumn
object for the column
at columnIndex
.
columnIndex | the index of the column desired |
---|
TableColumn
object for the column
at columnIndex
Returns the number of columns in the tableColumns
array.
tableColumns
arrayReturns the index of the first column in the tableColumns
array whose identifier is equal to identifier
,
when compared using equals
.
identifier | the identifier object |
---|
tableColumns
array whose identifier
is equal to identifier
IllegalArgumentException | if identifier
is null , or if no
TableColumn has this
identifier |
---|
Returns the index of the column that lies at position x
,
or -1 if no column covers this point.
In keeping with Swing's separable model architecture, a
TableColumnModel does not know how the table columns actually appear on
screen. The visual presentation of the columns is the responsibility
of the view/controller object using this model (typically JTable). The
view/controller need not display the columns sequentially from left to
right. For example, columns could be displayed from right to left to
accomodate a locale preference or some columns might be hidden at the
request of the user. Because the model does not know how the columns
are laid out on screen, the given xPosition
should not be
considered to be a coordinate in 2D graphics space. Instead, it should
be considered to be a width from the start of the first column in the
model. If the column index for a given X coordinate in 2D space is
required, JTable.columnAtPoint
can be used instead.
x | the horizontal location of interest |
---|
Returns the width margin for TableColumn
.
The default columnMargin
is 1.
TableColumn
Returns an array of all the column model listeners registered on this model.
ColumnModelListener
s
or an empty
array if no column model listeners are currently registeredReturns true if column selection is allowed, otherwise false. The default is false.
columnSelectionAllowed
property
Returns an Enumeration
of all the columns in the model.
Enumeration
of the columns in the model
Returns an array of all the objects currently registered
as FooListener
s
upon this model.
FooListener
s are registered using the
addFooListener
method.
You can specify the listenerType
argument
with a class literal,
such as
FooListener.class
.
For example, you can query a
DefaultTableColumnModel
m
for its column model listeners with the following code:
ColumnModelListener[] cmls = (ColumnModelListener[])(m.getListeners(ColumnModelListener.class));If no such listeners exist, this method returns an empty array.
listenerType | the type of listeners requested; this parameter
should specify an interface that descends from
java.util.EventListener |
---|
FooListener
s on this model,
or an empty array if no such
listeners have been addedClassCastException | if listenerType
doesn't specify a class or interface that implements
java.util.EventListener |
---|
Returns the number of columns selected.
Returns an array of selected columns. If selectionModel
is null
, returns an empty array.
selectionModel
is
null
Returns the ListSelectionModel
that is used to
maintain column selection state.
null
if row selection is not allowed.Returns the total combined width of all columns.
totalColumnWidth
property
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 a columnMoved
event to its listeners.
columnIndex | the index of column to be moved |
---|---|
newIndex | new index to move the column |
IllegalArgumentException | if column or
newIndex
are not in the valid range
|
---|
Property Change Listener change method. Used to track changes to the column width or preferred column width.
evt | PropertyChangeEvent
|
---|
Deletes the 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.
column | the TableColumn to be removed |
---|
Removes a listener for table column model events.
x | a TableColumnModelListener object
|
---|
Sets the column margin to newMargin
. This method
also posts a columnMarginChanged
event to its
listeners.
newMargin | the new margin width, in pixels |
---|
Sets whether column selection is allowed. The default is false.
flag | true if column selection will be allowed, false otherwise |
---|
Sets the selection model for this TableColumnModel
to newModel
and registers for listener notifications from the new selection
model. If newModel
is null
,
an exception is thrown.
newModel | the new selection model |
---|
IllegalArgumentException | if newModel
is null |
---|
A ListSelectionListener
that forwards
ListSelectionEvents
when there is a column
selection change.
e | the change event |
---|
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.
e | the event received |
---|
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.
e | the event received |
---|
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.
e | the event received |
---|
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.
e | the event received |
---|
Recalculates the total combined width of all columns. Updates the
totalColumnWidth
property.