org.jdesktop.swingx.table
Class TableColumnExt

java.lang.Object
  extended by javax.swing.table.TableColumn
      extended by org.jdesktop.swingx.table.TableColumnExt
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class TableColumnExt
extends javax.swing.table.TableColumn
implements java.lang.Cloneable

TableColumn extension which adds support for view column configuration features including column-visibility, sorting, and prototype values.

See Also:
Serialized Form

Field Summary
protected  boolean editable
           
protected  java.lang.Object prototypeValue
           
protected  Sorter sorter
           
static java.lang.String SORTER_COMPARATOR
           
protected  boolean visible
           
 
Fields inherited from class javax.swing.table.TableColumn
CELL_RENDERER_PROPERTY, cellEditor, cellRenderer, COLUMN_WIDTH_PROPERTY, HEADER_RENDERER_PROPERTY, HEADER_VALUE_PROPERTY, headerRenderer, headerValue, identifier, isResizable, maxWidth, minWidth, modelIndex, resizedPostingDisableCount, width
 
Constructor Summary
TableColumnExt()
          Creates new table view column with a model index = 0.
TableColumnExt(int modelIndex)
          Creates new table view column with the specified model index.
TableColumnExt(int modelIndex, int width)
          Creates new table view column with the specified model index and column width.
TableColumnExt(int modelIndex, int width, javax.swing.table.TableCellRenderer cellRenderer, javax.swing.table.TableCellEditor cellEditor)
          Creates new table view column with the specified model index, column width, cell renderer and cell editor.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this TableColumn.
protected  void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
           
 java.lang.Object getClientProperty(java.lang.Object key)
          Retrieves the object value using the specified key.
 java.lang.Object getPrototypeValue()
           
 boolean getResizable()
          cosmetic override: don't fool users if resize is not possible due to fixed column width.
 Sorter getSorter()
           
 java.lang.String getSorterClass()
           
 java.lang.String getTitle()
          Convenience method which returns the headerValue property after converting it to a string.
 boolean isEditable()
           
 boolean isSortable()
           
 boolean isVisible()
           
 void putClientProperty(java.lang.Object key, java.lang.Object value)
          Stores the object value using the specified key.
 void setEditable(boolean editable)
          Sets the editable property.
 void setPrototypeValue(java.lang.Object value)
          Sets the prototypeValue property.
 void setSorterClass(java.lang.String sorterClassName)
          Sets a user-defined sorter for this column
 void setTitle(java.lang.String title)
          Sets the title of this view column.
 void setVisible(boolean visible)
          Sets the visible property.
 
Methods inherited from class javax.swing.table.TableColumn
addPropertyChangeListener, createDefaultHeaderRenderer, disableResizedPosting, enableResizedPosting, getCellEditor, getCellRenderer, getHeaderRenderer, getHeaderValue, getIdentifier, getMaxWidth, getMinWidth, getModelIndex, getPreferredWidth, getPropertyChangeListeners, getWidth, removePropertyChangeListener, setCellEditor, setCellRenderer, setHeaderRenderer, setHeaderValue, setIdentifier, setMaxWidth, setMinWidth, setModelIndex, setPreferredWidth, setResizable, setWidth, sizeWidthToFit
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SORTER_COMPARATOR

public static final java.lang.String SORTER_COMPARATOR
See Also:
Constant Field Values

editable

protected boolean editable

visible

protected boolean visible

prototypeValue

protected java.lang.Object prototypeValue

sorter

protected Sorter sorter
Constructor Detail

TableColumnExt

public TableColumnExt()
Creates new table view column with a model index = 0.


TableColumnExt

public TableColumnExt(int modelIndex)
Creates new table view column with the specified model index.

Parameters:
modelIndex - index of table model column to which this view column is bound.

TableColumnExt

public TableColumnExt(int modelIndex,
                      int width)
Creates new table view column with the specified model index and column width.

Parameters:
modelIndex - index of table model column to which this view column is bound.
width - pixel width of view column

TableColumnExt

public TableColumnExt(int modelIndex,
                      int width,
                      javax.swing.table.TableCellRenderer cellRenderer,
                      javax.swing.table.TableCellEditor cellEditor)
Creates new table view column with the specified model index, column width, cell renderer and cell editor.

Parameters:
modelIndex - index of table model column to which this view column is bound.
width - pixel width of view column
cellRenderer - the cell renderer which will render all cells in this view column
cellEditor - the cell editor which will edit cells in this view column
Method Detail

getResizable

public boolean getResizable()
cosmetic override: don't fool users if resize is not possible due to fixed column width.

Overrides:
getResizable in class javax.swing.table.TableColumn

setEditable

public void setEditable(boolean editable)
Sets the editable property. This property enables the table view to control whether or not the user is permitted to edit cell values in this view column, even if the model permits. If the table model column corresponding to this view column returns true for isCellEditable and this property is false, then the user will not be permitted to edit values from this view column, dispite the model setting. If the model's isCellEditable returns false, then this property will be ignored and cell edits will not be permitted in this view column.

Parameters:
editable - boolean indicating whether or not the user may edit cell values in this view column
See Also:
isEditable(), TableModel.isCellEditable(int, int)

isEditable

public boolean isEditable()
Returns:
boolean indicating whether or not the user may edit cell values in this view column
See Also:
setEditable(boolean)

setPrototypeValue

public void setPrototypeValue(java.lang.Object value)
Sets the prototypeValue property. The value should be of a type which corresponds to the column's class as defined by the table model. If non-null, the JXTable instance will use this property to calculate and set the initial preferredWidth of the column. Note that this initial preferredWidth will be overridden if the user resizes columns directly.

Parameters:
value - Object containing the value of the prototype to be used to calculate the initial preferred width of the column
See Also:
getPrototypeValue(), JXTable.getPreferredScrollableViewportSize()

getPrototypeValue

public java.lang.Object getPrototypeValue()
Returns:
Object containing the value of the prototype to be used to calculate the initial preferred width of the column
See Also:
setPrototypeValue(java.lang.Object)

setSorterClass

public void setSorterClass(java.lang.String sorterClassName)
Sets a user-defined sorter for this column

Parameters:
sorterClassName - String containing the name of the class which performs sorting on this view column

getSorterClass

public java.lang.String getSorterClass()
Returns:
String containing the name of the class which performs sorting on this view column

getSorter

public Sorter getSorter()
Returns:
Sorter instance which performs sorting on this view column

isSortable

public boolean isSortable()
Returns:
boolean indicating whether this view column is sortable

setTitle

public void setTitle(java.lang.String title)
Sets the title of this view column. This is a convenience wrapper for setHeaderValue.

Parameters:
title - String containing the title of this view column

getTitle

public java.lang.String getTitle()
Convenience method which returns the headerValue property after converting it to a string.

Returns:
String containing the title of this view column

setVisible

public void setVisible(boolean visible)
Sets the visible property. This property controls whether or not this view column is currently visible in the table.

Parameters:
visible - boolean indicating whether or not this view column is visible in the table
See Also:
setVisible(boolean)

isVisible

public boolean isVisible()
Returns:
boolean indicating whether or not this view column is visible in the table
See Also:
setVisible(boolean)

putClientProperty

public void putClientProperty(java.lang.Object key,
                              java.lang.Object value)
Stores the object value using the specified key.

Parameters:
key - Object which is used as key to retrieve value
value - Object containing value of client property
See Also:
getClientProperty(java.lang.Object)

getClientProperty

public java.lang.Object getClientProperty(java.lang.Object key)
Retrieves the object value using the specified key.

Parameters:
key - Object which is used as key to retrieve value
Returns:
Object containing value of client property
See Also:
putClientProperty(java.lang.Object, java.lang.Object)

clone

public java.lang.Object clone()
Returns a clone of this TableColumn. Some implementations of TableColumn may assume that all TableColumnModels are unique, therefore it is recommended 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.

Overrides:
clone in class java.lang.Object
Returns:
a clone of this TableColumn

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)