TableColumn represents all the attributes of a column in a
JTable, such as width, resizability, minimum and maximum width.
In addition, the TableColumn provides slots for a renderer and
an editor that can be used to display and edit the values in this column.
It is also possible to specify renderers and editors on a per type basis
rather than a per column basis - see the
setDefaultRenderer method in the JTable class.
This default mechanism is only used when the renderer (or
editor) in the TableColumn is null.
The TableColumn stores the link between the columns in the
JTable and the columns in the TableModel.
The modelIndex is the column in the
TableModel, which will be queried for the data values for the
cells in this column. As the column moves around in the view this
modelIndex does not change.
Note
Some implementations may assume that all
TableColumnModels are unique, therefore we would
recommend that the same TableColumn instance
not be added more than once to a TableColumnModel.
To show TableColumns with the same column of
data from the model, create a new instance with the same
modelIndex.
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 JavaBeans
has been added to the java.beans package.
Please see java..
javax.swing.table.TableColumnModel , javax.swing.table.DefaultTableColumnModel , javax.swing.table.JTableHeader#getDefaultRenderer() , JTable#getDefaultRenderer(Class), JTable#getDefaultEditor(Class), JTable#getCellRenderer(int, int), JTable#getCellEditor(int, int)
| Modifier and Type | Field and Description |
|---|---|
| public static final String | CELL_RENDERER_PROPERTY
Obsolete as of Java 2 platform v1.3. |
| protected TableCellEditor | cellEditor
The editor used to edit the data cells of the column. |
| protected TableCellRenderer | cellRenderer
The renderer used to draw the data cells of the column. |
| private SwingPropertyChangeSupport | changeSupport
If any |
| public static final String | COLUMN_WIDTH_PROPERTY
Obsolete as of Java 2 platform v1.3. |
| public static final String | HEADER_RENDERER_PROPERTY
Obsolete as of Java 2 platform v1.3. |
| public static final String | HEADER_VALUE_PROPERTY
Obsolete as of Java 2 platform v1.3. |
| protected TableCellRenderer | headerRenderer
The renderer used to draw the header of the column. |
| protected Object | headerValue
The header value of the column. |
| protected Object | identifier
This object is not used internally by the drawing machinery of
the |
| protected boolean | isResizable
If true, the user is allowed to resize the column; the default is true. |
| protected int | maxWidth
The maximum width of the column. |
| protected int | minWidth
The minimum width of the column. |
| protected int | modelIndex
The index of the column in the model which is to be displayed by
this |
| private int | preferredWidth
The preferred width of the column. |
| protected transient int | resizedPostingDisableCount
Deprecated
as of Java 2 platform v1.3
This field was not used in previous releases and there are
currently no plans to support it in the future.
|
| protected int | width
The width of the column. |
| Access | Constructor and Description |
|---|---|
| public | TableColumn()
Cover method, using a default model index of 0,
default width of 75, a |
| public | TableColumn(int
the index of the column in the model
that supplies the data for this column in the table;
the model index remains the same even when columns
are reordered in the view modelIndex)Cover method, using a default width of 75, a |
| public | TableColumn(int
the index of the column in the model
that supplies the data for this column in the table;
the model index remains the same even when columns
are reordered in the view modelIndex, int this column's preferred width and initial width width)Cover method, using a |
| public | TableColumn(int
the index of the column
in the model that supplies the data for this column in the table;
the model index remains the same
even when columns are reordered in the view modelIndex, int this column's preferred width and initial width width, TableCellRenderer the object used to render values in this column cellRenderer, TableCellEditor the object used to edit values in this column cellEditor)Creates and initializes an instance of
|
| Modifier and Type | Method and Description |
|---|---|
| public synchronized void | addPropertyChangeListener(PropertyChangeListener
the listener to be added listener)Adds a |
| protected TableCellRenderer | Returns: the default header rendererAs of Java 2 platform v1.3, this method is not called by the |
| public void | disableResizedPosting()
Deprecated
as of Java 2 platform v1.3
This field was not used in previous releases and there are currently no plans to support it in the future. |
| public void | enableResizedPosting()
Deprecated
as of Java 2 platform v1.3
This field was not used in previous releases and there are currently no plans to support it in the future. |
| private void | |
| private void | |
| private void | |
| public TableCellEditor | Returns: thecellEditor propertyReturns the |
| public TableCellRenderer | Returns: thecellRenderer propertyReturns the |
| public TableCellRenderer | Returns: theheaderRenderer propertyReturns the |
| public Object | Returns: theheaderValue propertyReturns the |
| public Object | |
| public int | |
| public int | |
| public int | |
| public int | Returns: thepreferredWidth propertyReturns the preferred width of the |
| public synchronized PropertyChangeListener[] | Returns: all of thePropertyChangeListeners added or an empty
array if no listeners have been addedReturns an array of all the |
| public boolean | Returns: theisResizable propertyReturns true if the user is allowed to resize the
|
| public int | |
| public synchronized void | removePropertyChangeListener(PropertyChangeListener
the listener to be removed listener)Removes a |
| public void | setCellEditor(TableCellEditor
the new cellEditor cellEditor)Sets the editor to used by when a cell in this column is edited. |
| public void | setCellRenderer(TableCellRenderer
the new cellRenderer cellRenderer)Sets the |
| public void | setHeaderRenderer(TableCellRenderer
the new headerRenderer headerRenderer)Sets the |
| public void | setHeaderValue(Object
the new headerValue headerValue)Sets the |
| public void | setIdentifier(Object
an identifier for this column identifier)Sets the |
| public void | setMaxWidth(int
the new maximum width maxWidth)Sets the |
| public void | setMinWidth(int
the new minimum width minWidth)Sets the |
| public void | |
| public void | setPreferredWidth(int
the new preferred width preferredWidth)Sets this column's preferred width to |
| public void | setResizable(boolean
if true, resizing is allowed; otherwise false isResizable)Sets whether this column can be resized. |
| public void | setWidth(int
the new width width)This method should not be used to set the widths of columns in the
|
| public void |
| CELL_RENDERER_PROPERTY | back to summary |
|---|---|
| public static final String CELL_RENDERER_PROPERTY Obsolete as of Java 2 platform v1.3. Please use string literals to identify properties. | |
| cellEditor | back to summary |
|---|---|
| protected TableCellEditor cellEditor The editor used to edit the data cells of the column. | |
| cellRenderer | back to summary |
|---|---|
| protected TableCellRenderer cellRenderer The renderer used to draw the data cells of the column. | |
| changeSupport | back to summary |
|---|---|
| private SwingPropertyChangeSupport changeSupport If any | |
| COLUMN_WIDTH_PROPERTY | back to summary |
|---|---|
| public static final String COLUMN_WIDTH_PROPERTY Obsolete as of Java 2 platform v1.3. Please use string literals to identify properties. | |
| HEADER_RENDERER_PROPERTY | back to summary |
|---|---|
| public static final String HEADER_RENDERER_PROPERTY Obsolete as of Java 2 platform v1.3. Please use string literals to identify properties. | |
| HEADER_VALUE_PROPERTY | back to summary |
|---|---|
| public static final String HEADER_VALUE_PROPERTY Obsolete as of Java 2 platform v1.3. Please use string literals to identify properties. | |
| headerRenderer | back to summary |
|---|---|
| protected TableCellRenderer headerRenderer The renderer used to draw the header of the column. | |
| headerValue | back to summary |
|---|---|
| protected Object headerValue The header value of the column. | |
| identifier | back to summary |
|---|---|
| protected Object identifier This object is not used internally by the drawing machinery of
the | |
| isResizable | back to summary |
|---|---|
| protected boolean isResizable If true, the user is allowed to resize the column; the default is true. | |
| maxWidth | back to summary |
|---|---|
| protected int maxWidth The maximum width of the column. | |
| minWidth | back to summary |
|---|---|
| protected int minWidth The minimum width of the column. | |
| modelIndex | back to summary |
|---|---|
| protected int modelIndex The index of the column in the model which is to be displayed by
this | |
| preferredWidth | back to summary |
|---|---|
| private int preferredWidth The preferred width of the column. | |
| resizedPostingDisableCount | back to summary |
|---|---|
| protected transient int resizedPostingDisableCount
Deprecated as of Java 2 platform v1.3 This field was not used in previous releases and there are currently no plans to support it in the future. | |
| width | back to summary |
|---|---|
| protected int width The width of the column. | |
| TableColumn | back to summary |
|---|---|
| public TableColumn() Cover method, using a default model index of 0,
default width of 75, a | |
| TableColumn | back to summary |
|---|---|
| public TableColumn(int modelIndex) Cover method, using a default width of 75, a
| |
| TableColumn | back to summary |
|---|---|
| public TableColumn(int modelIndex, int width) Cover method, using a
| |
| TableColumn | back to summary |
|---|---|
| public TableColumn(int modelIndex, int width, TableCellRenderer cellRenderer, TableCellEditor cellEditor) Creates and initializes an instance of
When the
| |
| addPropertyChangeListener | back to summary |
|---|---|
| public synchronized void addPropertyChangeListener(PropertyChangeListener listener) Adds a
| |
| createDefaultHeaderRenderer | back to summary |
|---|---|
| protected TableCellRenderer createDefaultHeaderRenderer() As of Java 2 platform v1.3, this method is not called by the
| |
| disableResizedPosting | back to summary |
|---|---|
| public void disableResizedPosting()
Deprecated as of Java 2 platform v1.3 This field was not used in previous releases and there are currently no plans to support it in the future.
| |
| enableResizedPosting | back to summary |
|---|---|
| public void enableResizedPosting()
Deprecated as of Java 2 platform v1.3 This field was not used in previous releases and there are currently no plans to support it in the future.
| |
| firePropertyChange | back to summary |
|---|---|
| private void firePropertyChange(String propertyName, Object oldValue, Object newValue) | |
| firePropertyChange | back to summary |
|---|---|
| private void firePropertyChange(String propertyName, int oldValue, int newValue) | |
| firePropertyChange | back to summary |
|---|---|
| private void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) | |
| getCellEditor | back to summary |
|---|---|
| public TableCellEditor getCellEditor() Returns the
| |
| getCellRenderer | back to summary |
|---|---|
| public TableCellRenderer getCellRenderer() Returns the
| |
| getHeaderRenderer | back to summary |
|---|---|
| public TableCellRenderer getHeaderRenderer() Returns the
| |
| getHeaderValue | back to summary |
|---|---|
| public Object getHeaderValue() Returns the
| |
| getIdentifier | back to summary |
|---|---|
| public Object getIdentifier() Returns the
| |
| getMaxWidth | back to summary |
|---|---|
| public int getMaxWidth() Returns the maximum width for the
| |
| getMinWidth | back to summary |
|---|---|
| public int getMinWidth() Returns the minimum width for the
| |
| getModelIndex | back to summary |
|---|---|
| public int getModelIndex() Returns the model index for this column.
| |
| getPreferredWidth | back to summary |
|---|---|
| public int getPreferredWidth() Returns the preferred width of the
| |
| getPropertyChangeListeners | back to summary |
|---|---|
| public synchronized PropertyChangeListener[] getPropertyChangeListeners() Returns an array of all the
| |
| getResizable | back to summary |
|---|---|
| public boolean getResizable() Returns true if the user is allowed to resize the
| |
| getWidth | back to summary |
|---|---|
| public int getWidth() Returns the width of the
| |
| removePropertyChangeListener | back to summary |
|---|---|
| public synchronized void removePropertyChangeListener(PropertyChangeListener listener) Removes a
| |
| setCellEditor | back to summary |
|---|---|
| public void setCellEditor(TableCellEditor cellEditor) Sets the editor to used by when a cell in this column is edited.
| |
| setCellRenderer | back to summary |
|---|---|
| public void setCellRenderer(TableCellRenderer cellRenderer) Sets the
| |
| setHeaderRenderer | back to summary |
|---|---|
| public void setHeaderRenderer(TableCellRenderer headerRenderer) Sets the It is the header renderers responsibility to render the sorting indicator. If you are using sorting and specify a renderer your renderer must render the sorting indication.
| |
| setHeaderValue | back to summary |
|---|---|
| public void setHeaderValue(Object headerValue) Sets the
| |
| setIdentifier | back to summary |
|---|---|
| public void setIdentifier(Object identifier) Sets the Note identifiers are not used by the
| |
| setMaxWidth | back to summary |
|---|---|
| public void setMaxWidth(int maxWidth) Sets the
If the value of the
| |
| setMinWidth | back to summary |
|---|---|
| public void setMinWidth(int minWidth) Sets the
If the value of the
| |
| setModelIndex | back to summary |
|---|---|
| public void setModelIndex(int modelIndex) Sets the model index for this column. The model index is the
index of the column in the model that will be displayed by this
| |
| setPreferredWidth | back to summary |
|---|---|
| public void setPreferredWidth(int preferredWidth) Sets this column's preferred width to
For details on how the widths of columns in the
| |
| setResizable | back to summary |
|---|---|
| public void setResizable(boolean isResizable) Sets whether this column can be resized.
| |
| setWidth | back to summary |
|---|---|
| public void setWidth(int width) This method should not be used to set the widths of columns in the
This method sets this column's width to
| |
| sizeWidthToFit | back to summary |
|---|---|
| public void sizeWidthToFit() Resizes the
| |