javax.swing.table

Class TableColumn

Implemented Interfaces:
Serializable

public class TableColumn
extends Object
implements Serializable

Represents the attributes of a column in a table, including the column index, width, minimum width, preferred width and maximum width.
See Also:
Serialized Form

Field Summary

static String
CELL_RENDERER_PROPERTY
The name for the cellRenderer property.
static String
COLUMN_WIDTH_PROPERTY
The name for the columnWidth property.
static String
HEADER_RENDERER_PROPERTY
The name for the headerRenderer property.
static String
HEADER_VALUE_PROPERTY
The name for the headerValue property.
protected TableCellEditor
cellEditor
cellEditor
protected TableCellRenderer
cellRenderer
cellRenderer
protected TableCellRenderer
headerRenderer
headerRenderer
protected Object
headerValue
The header value.
protected Object
identifier
The identifier for the column.
protected boolean
isResizable
isResizable
protected int
maxWidth
The maximum width.
protected int
minWidth
The minimum width.
protected int
modelIndex
The index of the corresponding column in the table model.
protected int
resizedPostingDisableCount
Deprecated. 1.3
protected int
width
The width.

Constructor Summary

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.

Method Summary

void
addPropertyChangeListener(PropertyChangeListener listener)
Adds a property change listener.
protected TableCellRenderer
createDefaultHeaderRenderer()
createDefaultHeaderRenderer
void
disableResizedPosting()
Deprecated. 1.3
void
enableResizedPosting()
Deprecated. 1.3
TableCellEditor
getCellEditor()
getCellEditor
TableCellRenderer
getCellRenderer()
Returns the renderer for the table cells in this column.
TableCellRenderer
getHeaderRenderer()
getHeaderRenderer
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.
int
getMinWidth()
Returns the TableColumn's minimum width.
int
getModelIndex()
Returns the index of the column in the related TableModel that this TableColumn maps to.
int
getPreferredWidth()
getPreferredWidth
PropertyChangeListener[]
getPropertyChangeListeners()
Returns the property change listeners for this TableColumn.
boolean
getResizable()
getResizable
int
getWidth()
getWidth
void
removePropertyChangeListener(PropertyChangeListener listener)
removePropertyChangeListener
void
setCellEditor(TableCellEditor cellEditor)
setCellEditor
void
setCellRenderer(TableCellRenderer renderer)
Sets the renderer for cells in this column and sends a PropertyChangeEvent to all registered listeners.
void
setHeaderRenderer(TableCellRenderer renderer)
setHeaderRenderer
void
setHeaderValue(Object headerValue)
Sets the header value and sends a PropertyChangeEvent to all registered listeners.
void
setIdentifier(Object identifier)
Sets the identifier for the column.
void
setMaxWidth(int maxWidth)
Sets the maximum width and, if necessary, updates the width and preferredWidth.
void
setMinWidth(int minWidth)
Sets the minimum width for the column and, if necessary, updates the width and preferredWidth.
void
setModelIndex(int modelIndex)
Sets the index of the column in the related TableModel that this TableColumn maps to.
void
setPreferredWidth(int preferredWidth)
setPreferredWidth
void
setResizable(boolean isResizable)
setResizable
void
setWidth(int newWidth)
setWidth
void
sizeWidthToFit()
sizeWidthToFit

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

CELL_RENDERER_PROPERTY

public static final String CELL_RENDERER_PROPERTY
The name for the cellRenderer property.
Field Value:
"cellRenderer"

COLUMN_WIDTH_PROPERTY

public static final String COLUMN_WIDTH_PROPERTY
The name for the columnWidth property. Note that the typo in the name value is deliberate, to match the specification.
Field Value:
"columWidth"

HEADER_RENDERER_PROPERTY

public static final String HEADER_RENDERER_PROPERTY
The name for the headerRenderer property.
Field Value:
"headerRenderer"

HEADER_VALUE_PROPERTY

public static final String HEADER_VALUE_PROPERTY
The name for the headerValue property.
Field Value:
"headerValue"

cellEditor

protected TableCellEditor cellEditor
cellEditor

cellRenderer

protected TableCellRenderer cellRenderer
cellRenderer

headerRenderer

protected TableCellRenderer headerRenderer
headerRenderer

headerValue

protected Object headerValue
The header value.

identifier

protected Object identifier
The identifier for the column.

isResizable

protected boolean isResizable
isResizable

maxWidth

protected int maxWidth
The maximum width.

minWidth

protected int minWidth
The minimum width.

modelIndex

protected int modelIndex
The index of the corresponding column in the table model.

resizedPostingDisableCount

protected int resizedPostingDisableCount

Deprecated. 1.3

resizedPostingDisableCount

width

protected int width
The width.

Constructor Details

TableColumn

public TableColumn()
Creates a new TableColumn that maps to column 0 in the related table model. The default width is 75 units.

TableColumn

public TableColumn(int modelIndex)
Creates a new TableColumn that maps to the specified column in the related table model. The default width is 75 units.
Parameters:
modelIndex - the index of the column in the model

TableColumn

public 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.
Parameters:
modelIndex - the index of the column in the model
width - the width

TableColumn

public 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.
Parameters:
modelIndex - the index of the column in the model
width - the width
cellRenderer - the cell renderer (null permitted).
cellEditor - the cell editor (null permitted).

Method Details

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a property change listener.
Parameters:
listener - the listener to add

createDefaultHeaderRenderer

protected TableCellRenderer createDefaultHeaderRenderer()
createDefaultHeaderRenderer
Returns:
TableCellRenderer

disableResizedPosting

public void disableResizedPosting()

Deprecated. 1.3

This method is empty, unused and deprecated.

enableResizedPosting

public void enableResizedPosting()

Deprecated. 1.3

This method is empty, unused and deprecated.

getCellEditor

public TableCellEditor getCellEditor()
getCellEditor
Returns:
the cell editor

getCellRenderer

public TableCellRenderer getCellRenderer()
Returns the renderer for the table cells in this column.
Returns:
The cell renderer.

getHeaderRenderer

public TableCellRenderer getHeaderRenderer()
getHeaderRenderer
Returns:
TableCellRenderer

getHeaderValue

public Object getHeaderValue()
Returns the header value.
Returns:
the value of the header

getIdentifier

public Object getIdentifier()
Returns the identifier for the column, or getHeaderValue() if the identifier is null.
Returns:
The identifier (or getHeaderValue() if the identifier is null).

getMaxWidth

public int getMaxWidth()
Returns the maximum width.
Returns:
The maximum width.

getMinWidth

public int getMinWidth()
Returns the TableColumn's minimum width.
Returns:
The minimum width.

getModelIndex

public int getModelIndex()
Returns the index of the column in the related TableModel that this TableColumn maps to.
Returns:
the model index

getPreferredWidth

public int getPreferredWidth()
getPreferredWidth
Returns:
the preferred width

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners()
Returns the property change listeners for this TableColumn.
Since:
1.4

getResizable

public boolean getResizable()
getResizable
Returns:
true if this column is resizable, false otherwise

getWidth

public int getWidth()
getWidth
Returns:
int

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
removePropertyChangeListener
Parameters:
listener - the listener to remove

setCellEditor

public void setCellEditor(TableCellEditor cellEditor)
setCellEditor
Parameters:
cellEditor - the cell editor

setCellRenderer

public void setCellRenderer(TableCellRenderer renderer)
Sets the renderer for cells in this column and sends a PropertyChangeEvent to all registered listeners.
Parameters:
renderer - the cell renderer (null permitted).

setHeaderRenderer

public void setHeaderRenderer(TableCellRenderer renderer)
setHeaderRenderer
Parameters:
renderer - the renderer to use

setHeaderValue

public void setHeaderValue(Object headerValue)
Sets the header value and sends a PropertyChangeEvent to all registered listeners. The header value property uses the name HEADER_VALUE_PROPERTY.
Parameters:
headerValue - the value of the header

setIdentifier

public void setIdentifier(Object identifier)
Sets the identifier for the column.
Parameters:
identifier - the identifier

setMaxWidth

public void setMaxWidth(int maxWidth)
Sets the maximum width and, if necessary, updates the width and preferredWidth.
Parameters:
maxWidth - the maximum width

setMinWidth

public void setMinWidth(int minWidth)
Sets the minimum width for the column and, if necessary, updates the width and preferredWidth.
Parameters:
minWidth - the minimum width

setModelIndex

public void setModelIndex(int modelIndex)
Sets the index of the column in the related TableModel that this TableColumn maps to.
Parameters:
modelIndex - the column index in the model.

setPreferredWidth

public void setPreferredWidth(int preferredWidth)
setPreferredWidth
Parameters:
preferredWidth - the preferred width

setResizable

public void setResizable(boolean isResizable)
setResizable
Parameters:
isResizable - true if this column is resizable, false otherwise

setWidth

public void setWidth(int newWidth)
setWidth
Parameters:
newWidth - the width

sizeWidthToFit

public void sizeWidthToFit()
sizeWidthToFit

TableColumn.java -- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.