javax.swing.table
public class TableColumn extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
static String |
CELL_RENDERER_PROPERTY
The name for the
cellRenderer property. |
protected TableCellEditor |
cellEditor
An editor for the regular cells in this column.
|
protected TableCellRenderer |
cellRenderer
The renderer for the regular cells in this column.
|
static String |
COLUMN_WIDTH_PROPERTY
The name for the
columnWidth property (this field is
obsolete and no longer used). |
static String |
HEADER_RENDERER_PROPERTY
The name for the
headerRenderer property. |
static String |
HEADER_VALUE_PROPERTY
The name for the
headerValue property. |
protected TableCellRenderer |
headerRenderer
The renderer for the column header.
|
protected Object |
headerValue
The value for the column header.
|
protected Object |
identifier
The identifier for the column.
|
protected boolean |
isResizable
A flag that determines whether or not the column is resizable (the default
is
true ). |
protected int |
maxWidth
The maximum width for the column.
|
protected int |
minWidth
The minimum width for the column.
|
protected int |
modelIndex
The index of the corresponding column in the table model.
|
protected int |
resizedPostingDisableCount
Deprecated.
1.3
|
protected int |
width
The current width for the column.
|
Constructor and Description |
---|
TableColumn()
Creates a new
TableColumn that maps to column 0 in the
related table model. |
TableColumn(int modelIndex)
Creates a new
TableColumn that maps to the specified column
in the related table model. |
TableColumn(int modelIndex,
int width)
Creates a new
TableColumn that maps to the specified column
in the related table model, and has the specified width . |
TableColumn(int modelIndex,
int width,
TableCellRenderer cellRenderer,
TableCellEditor cellEditor)
Creates a new
TableColumn that maps to the specified column
in the related table model, and has the specified width ,
cellRenderer and cellEditor . |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener so that it receives
PropertyChangeEvent
notifications from this column. |
protected TableCellRenderer |
createDefaultHeaderRenderer()
Creates and returns a default renderer for the column header (in this case,
a new instance of
DefaultTableCellRenderer ). |
void |
disableResizedPosting()
Deprecated.
1.3
|
void |
enableResizedPosting()
Deprecated.
1.3
|
TableCellEditor |
getCellEditor()
Returns the cell editor for the column (the default value is
null ). |
TableCellRenderer |
getCellRenderer()
Returns the renderer for the table cells in this column.
|
TableCellRenderer |
getHeaderRenderer()
Returns the renderer for the column header.
|
Object |
getHeaderValue()
Returns the header value.
|
Object |
getIdentifier()
Returns the identifier for the column, or
getHeaderValue() if the
identifier is null . |
int |
getMaxWidth()
Returns the maximum width for the column (the default value is
Integer.MAX_VALUE ). |
int |
getMinWidth()
Returns the
TableColumn 's minimum width (the default value
is 15 ). |
int |
getModelIndex()
Returns the index of the column in the related
TableModel that
this TableColumn maps to. |
int |
getPreferredWidth()
Returns the preferred width for the column (the default value is
75 ). |
PropertyChangeListener[] |
getPropertyChangeListeners()
Returns the property change listeners for this
TableColumn . |
boolean |
getResizable()
Returns the flag that controls whether or not the column is resizable.
|
int |
getWidth()
Returns the width for the column (the default value is
75 ). |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a listener so that it no longer receives
PropertyChangeEvent notifications from this column. |
void |
setCellEditor(TableCellEditor cellEditor)
Sets the cell editor for the column and sends a
PropertyChangeEvent
(with the property name 'cellEditor') to all registered listeners. |
void |
setCellRenderer(TableCellRenderer renderer)
Sets the renderer for cells in this column and sends a
PropertyChangeEvent (with the property name
CELL_RENDERER_PROPERTY ) to all registered listeners. |
void |
setHeaderRenderer(TableCellRenderer renderer)
Sets the renderer for the column header and sends a
PropertyChangeEvent (with the property name
HEADER_RENDERER_PROPERTY ) to all registered listeners. |
void |
setHeaderValue(Object headerValue)
Sets the header value and sends a
PropertyChangeEvent (with the
property name HEADER_VALUE_PROPERTY ) to all registered listeners. |
void |
setIdentifier(Object identifier)
Sets the identifier for the column and sends a
PropertyChangeEvent
(with the property name 'identifier') to all registered listeners. |
void |
setMaxWidth(int maxWidth)
Sets the maximum width for the column and sends a
PropertyChangeEvent (with the property name 'maxWidth') to all
registered listeners. |
void |
setMinWidth(int minWidth)
Sets the minimum width for the column and sends a
PropertyChangeEvent (with the property name 'minWidth') to all
registered listeners. |
void |
setModelIndex(int modelIndex)
Sets the index of the column in the related
TableModel that this
TableColumn maps to, and sends a PropertyChangeEvent
(with the property name 'modelIndex') to all registered listeners. |
void |
setPreferredWidth(int preferredWidth)
Sets the preferred width for the column and sends a
PropertyChangeEvent (with the property name 'preferredWidth') to
all registered listeners. |
void |
setResizable(boolean isResizable)
Sets the flag that controls whether or not the column is resizable, and
sends a
PropertyChangeEvent (with the property name 'isResizable')
to all registered listeners. |
void |
setWidth(int newWidth)
Sets the width for the column and sends a
PropertyChangeEvent
(with the property name 'width') to all registered listeners. |
void |
sizeWidthToFit()
Sets the minimum, maximum, preferred and current width to match the
minimum, maximum and preferred width of the header renderer component.
|
public static final String COLUMN_WIDTH_PROPERTY
columnWidth
property (this field is
obsolete and no longer used). Note also that the typo in the value
string is deliberate, to match the specification.public static final String HEADER_VALUE_PROPERTY
headerValue
property.public static final String HEADER_RENDERER_PROPERTY
headerRenderer
property.public static final String CELL_RENDERER_PROPERTY
cellRenderer
property.protected int modelIndex
protected Object identifier
protected int width
protected int minWidth
protected int maxWidth
protected TableCellRenderer headerRenderer
protected Object headerValue
protected TableCellRenderer cellRenderer
protected TableCellEditor cellEditor
protected boolean isResizable
true
).protected transient int resizedPostingDisableCount
public TableColumn()
TableColumn
that maps to column 0 in the
related table model. The default width is 75
units.public TableColumn(int modelIndex)
TableColumn
that maps to the specified column
in the related table model. The default width is 75
units.modelIndex
- the index of the column in the modelpublic TableColumn(int modelIndex, int width)
TableColumn
that maps to the specified column
in the related table model, and has the specified width
.modelIndex
- the index of the column in the modelwidth
- the widthpublic TableColumn(int modelIndex, int width, TableCellRenderer cellRenderer, TableCellEditor cellEditor)
TableColumn
that maps to the specified column
in the related table model, and has the specified width
,
cellRenderer
and cellEditor
.modelIndex
- the index of the column in the modelwidth
- the widthcellRenderer
- the cell renderer (null
permitted).cellEditor
- the cell editor (null
permitted).public void setModelIndex(int modelIndex)
TableModel
that this
TableColumn
maps to, and sends a PropertyChangeEvent
(with the property name 'modelIndex') to all registered listeners.modelIndex
- the column index in the model.getModelIndex()
public int getModelIndex()
TableModel
that
this TableColumn
maps to.setModelIndex(int)
public void setIdentifier(Object identifier)
PropertyChangeEvent
(with the property name 'identifier') to all registered listeners.identifier
- the identifier (null
permitted).getIdentifier()
public Object getIdentifier()
getHeaderValue()
if the
identifier is null
.getHeaderValue()
if the identifier is
null
).public void setHeaderValue(Object headerValue)
PropertyChangeEvent
(with the
property name HEADER_VALUE_PROPERTY
) to all registered listeners.headerValue
- the value of the header (null
permitted).getHeaderValue()
public Object getHeaderValue()
getHeaderValue()
public void setHeaderRenderer(TableCellRenderer renderer)
PropertyChangeEvent
(with the property name
HEADER_RENDERER_PROPERTY
) to all registered listeners.renderer
- the header renderer (null
permitted).getHeaderRenderer()
public TableCellRenderer getHeaderRenderer()
null
).setHeaderRenderer(TableCellRenderer)
public void setCellRenderer(TableCellRenderer renderer)
PropertyChangeEvent
(with the property name
CELL_RENDERER_PROPERTY
) to all registered listeners.renderer
- the cell renderer (null
permitted).getCellRenderer()
public TableCellRenderer getCellRenderer()
null
).setCellRenderer(TableCellRenderer)
public void setCellEditor(TableCellEditor cellEditor)
PropertyChangeEvent
(with the property name 'cellEditor') to all registered listeners.cellEditor
- the cell editor (null
permitted).getCellEditor()
public TableCellEditor getCellEditor()
null
).null
).setCellEditor(TableCellEditor)
public void setWidth(int newWidth)
PropertyChangeEvent
(with the property name 'width') to all registered listeners. If the new
width falls outside the range getMinWidth() to getMaxWidth() it is
adjusted to the appropriate boundary value.newWidth
- the width.getWidth()
public int getWidth()
75
).setWidth(int)
public void setPreferredWidth(int preferredWidth)
PropertyChangeEvent
(with the property name 'preferredWidth') to
all registered listeners. If necessary, the supplied value will be
adjusted to fit in the range getMinWidth()
to
getMaxWidth()
.preferredWidth
- the preferred width.getPreferredWidth()
public int getPreferredWidth()
75
).setPreferredWidth(int)
public void setMinWidth(int minWidth)
PropertyChangeEvent
(with the property name 'minWidth') to all
registered listeners. If the current width
and/or
preferredWidth
are less than the new minimum width, they are
adjusted accordingly.minWidth
- the minimum width (negative values are treated as 0).getMinWidth()
public int getMinWidth()
TableColumn
's minimum width (the default value
is 15
).setMinWidth(int)
public void setMaxWidth(int maxWidth)
PropertyChangeEvent
(with the property name 'maxWidth') to all
registered listeners. If the current width
and/or
preferredWidth
are greater than the new maximum width, they
are adjusted accordingly.maxWidth
- the maximum width.getMaxWidth()
public int getMaxWidth()
Integer.MAX_VALUE
).setMaxWidth(int)
public void setResizable(boolean isResizable)
PropertyChangeEvent
(with the property name 'isResizable')
to all registered listeners.isResizable
- true
if this column is resizable,
false
otherwise.getResizable()
public boolean getResizable()
true
if this column is resizable,
false
otherwise.setResizable(boolean)
public void sizeWidthToFit()
public void disableResizedPosting()
public void enableResizedPosting()
public void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeEvent
notifications from this column. The properties defined by the column are:
width
- see setWidth(int)
;preferredWidth
- see setPreferredWidth(int)
;minWidth
- see setMinWidth(int)
;maxWidth
- see setMaxWidth(int)
;modelIndex
- see setModelIndex(int)
;isResizable
- see setResizable(boolean)
;cellRenderer
- see
setCellRenderer(TableCellRenderer)
;cellEditor
- see
setCellEditor(TableCellEditor)
;headerRenderer
- see
setHeaderRenderer(TableCellRenderer)
;headerValue
- see setHeaderValue(Object)
;identifier
- see setIdentifier(Object)
.listener
- the listener to add (null
is ignored).removePropertyChangeListener(PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeEvent
notifications from this column. If
listener
is not registered with the column, or is
null
, this method does nothing.listener
- the listener to remove (null
is ignored).public PropertyChangeListener[] getPropertyChangeListeners()
TableColumn
.
An empty array is returned if there are currently no listeners registered.protected TableCellRenderer createDefaultHeaderRenderer()
DefaultTableCellRenderer
).