Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.swing.table
Class DefaultTableColumnModel

    java.lang.Object
      |
      +--javax.swing.table.DefaultTableColumnModel

public class DefaultTableColumnModel
extends java.lang.Object
implements TableColumnModel, java.beans.PropertyChangeListener, ListSelectionListener, java.io.Serializable

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. A future release of Swing will provide support for long term persistence.

See Also:
  `JTable`, Serialized Form

Field Summary
`protected ChangeEvent` | `changeEvent` Change event (only one needed)
`protected int` | `columnMargin` Width margin between each column
`protected boolean` | `columnSelectionAllowed` Column selection allowed in this column model
`protected EventListenerList` | `listenerList` List of TableColumnModelListener
`protected ListSelectionModel` | `selectionModel` Model for keeping track of column selections
`protected java.util.Vector` | `tableColumns` Array of TableColumn objects in this model
`protected int` | `totalColumnWidth` A local cache of the combined width of all columns

Constructor Summary
`DefaultTableColumnModel()` Creates a default table column model.

Method Summary
`void` | `addColumn(TableColumn aColumn)` Appends aColumn to the end of the receiver's tableColumns array.
`void` | `addColumnModelListener(TableColumnModelListener x)`
`protected ListSelectionModel` | `createSelectionModel()`
`protected void` | `fireColumnAdded(TableColumnModelEvent e)`
`protected void` | `fireColumnMarginChanged()`
`protected void` | `fireColumnMoved(TableColumnModelEvent e)`
`protected void` | `fireColumnRemoved(TableColumnModelEvent e)`
`protected void` | `fireColumnSelectionChanged(ListSelectionEvent e)`
`TableColumn` | `getColumn(int columnIndex)` Returns the TableColumn object for the column at columnIndex
`int` | `getColumnCount()` Returns the number of columns in the receiver's table columns array.
`int` | `getColumnIndex(java.lang.Object identifier)` Returns the index of the first column in the receiver's columns array whose identifier is equal to identifier, when compared using equals().
`int` | `getColumnIndexAtX(int xPosition)` Returns the index of the column that lies on the xPosition, or -1 if it lies outside the any of the column's bounds.
`int` | `getColumnMargin()` Returns the width margin for TableColumn.
`java.util.Enumeration` | `getColumns()` Returns an Enumeration of all the columns in the model
`boolean` | `getColumnSelectionAllowed()`
`int` | `getSelectedColumnCount()`
`int[]` | `getSelectedColumns()`
`ListSelectionModel` | `getSelectionModel()` Returns the ListSelectionModel that is used to maintain column selection state.
`int` | `getTotalColumnWidth()`
`void` | `moveColumn(int columnIndex, int newIndex)` Moves the column and heading at columnIndex to newIndex.
`void` | `propertyChange(java.beans.PropertyChangeEvent evt)`
`protected void` | `recalcWidthCache()`
`void` | `removeColumn(TableColumn column)` Deletes the TableColumn column from the receiver's table columns array.
`void` | `removeColumnModelListener(TableColumnModelListener x)`
`void` | `setColumnMargin(int newMargin)` Sets the column margin to newMargin.
`void` | `setColumnSelectionAllowed(boolean flag)`
`void` | `setSelectionModel(ListSelectionModel newModel)` Sets the selection model for this TableColumnModel to newModel and registers with for listner notifications from the new selection model.
`void` | `valueChanged(ListSelectionEvent e)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### tableColumns

    protected java.util.Vector tableColumns

  Array of TableColumn objects in this model

### selectionModel

    protected ListSelectionModel selectionModel

  Model for keeping track of column selections

### columnMargin

    protected int columnMargin

  Width margin between each column

### listenerList

    protected EventListenerList listenerList

  List of TableColumnModelListener

### changeEvent

    protected transient ChangeEvent changeEvent

  Change event (only one needed)

### columnSelectionAllowed

    protected boolean columnSelectionAllowed

  Column selection allowed in this column model

### totalColumnWidth

    protected int totalColumnWidth

  A local cache of the combined width of all columns

Constructor Detail

### DefaultTableColumnModel

    public DefaultTableColumnModel()

  Creates a default table column model.

Method Detail

### addColumn

    public void addColumn(TableColumn aColumn)

  Appends aColumn to the end of the receiver's tableColumns array. This method also posts the columnAdded() event to its listeners.
  Specified by:
    addColumn in interface TableColumnModel
  Parameters:
    `column` - The TableColumn to be added
  Throws:
    java.lang.IllegalArgumentException - if aColumn is null
  See Also:
    `removeColumn(javax.swing.table.TableColumn)`

### removeColumn

    public void removeColumn(TableColumn column)

  Deletes the TableColumn column from the receiver's table columns 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 the columnRemoved() event to its listeners.
  Specified by:
    removeColumn in interface TableColumnModel
  Parameters:
    `column` - The TableColumn to be removed
  See Also:
    `addColumn(javax.swing.table.TableColumn)`

### moveColumn

    public void moveColumn(int columnIndex,
                           int newIndex)

  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 the columnMoved() event to its listeners.
  Specified by:
    moveColumn in interface TableColumnModel
  Parameters:
    `columnIndex` - the index of column to be moved
    `newIndex` - New index to move the column
  Throws:
    java.lang.IllegalArgumentException - if column or newIndex are not in the valid range

### setColumnMargin

    public void setColumnMargin(int newMargin)

  Sets the column margin to newMargin. This method also posts the columnMarginChanged() event to its listeners.
  Specified by:
    setColumnMargin in interface TableColumnModel
  Parameters:
    `newMargin` - the width margin of the column
  See Also:
    `getColumnMargin()`, `getTotalColumnWidth()`

### getColumnCount

    public int getColumnCount()

  Returns the number of columns in the receiver's table columns array.
  Specified by:
    getColumnCount in interface TableColumnModel
  Returns:
    the number of columns in the receiver's table columns array
  See Also:
    `getColumns()`

### getColumns

    public java.util.Enumeration getColumns()

  Returns an Enumeration of all the columns in the model
  Specified by:
    getColumns in interface TableColumnModel

### getColumnIndex

    public int getColumnIndex(java.lang.Object identifier)

  Returns the index of the first column in the receiver's columns array whose identifier is equal to identifier, when compared using equals().
  Specified by:
    getColumnIndex in interface TableColumnModel
  Parameters:
    `identifier` - the identifier object
  Returns:
    the index of the first table column in the receiver's tableColumns array whose identifier is equal to identifier, when compared using equals().
  Throws:
    java.lang.IllegalArgumentException - if identifier is null or no TableColumn has this identifier
  See Also:
    `getColumn(int)`

### getColumn

    public TableColumn getColumn(int columnIndex)

  Returns the TableColumn object for the column at columnIndex
  Specified by:
    getColumn in interface TableColumnModel
  Parameters:
    `columnIndex` - the index of the column desired
  Returns:
    the TableColumn object for the column at columnIndex

### getColumnMargin

    public int getColumnMargin()

  Returns the width margin for TableColumn. The default columnMargin is 1.
  Specified by:
    getColumnMargin in interface TableColumnModel
  Returns:
    the maximum width for the TableColumn.
  See Also:
    `setColumnMargin(int)`

### getColumnIndexAtX

    public int getColumnIndexAtX(int xPosition)

  Returns the index of the column that lies on the xPosition, or -1 if it lies outside the any of the column's bounds.
  Specified by:
    getColumnIndexAtX in interface TableColumnModel
  Returns:
    the index of the column or -1 if no column is found

### getTotalColumnWidth

    public int getTotalColumnWidth()

  Specified by:
    getTotalColumnWidth in interface TableColumnModel

### setSelectionModel

    public void setSelectionModel(ListSelectionModel newModel)

  Sets the selection model for this TableColumnModel to newModel and registers with for listner notifications from the new selection model. If newModel is null, it means columns are not selectable.
  Specified by:
    setSelectionModel in interface TableColumnModel
  Parameters:
    `newModel` - the new selection model
  See Also:
    `getSelectionModel()`

### getSelectionModel

    public ListSelectionModel getSelectionModel()

  Returns the ListSelectionModel that is used to maintain column selection state.
  Specified by:
    getSelectionModel in interface TableColumnModel
  Returns:
    the object that provides column selection state. Or null if row selection is not allowed.
  See Also:
    `#setSelectionModel()`

### setColumnSelectionAllowed

    public void setColumnSelectionAllowed(boolean flag)

  Specified by:
    setColumnSelectionAllowed in interface TableColumnModel

### getColumnSelectionAllowed

    public boolean getColumnSelectionAllowed()

  Specified by:
    getColumnSelectionAllowed in interface TableColumnModel

### getSelectedColumns

    public int[] getSelectedColumns()

  Specified by:
    getSelectedColumns in interface TableColumnModel

### getSelectedColumnCount

    public int getSelectedColumnCount()

  Specified by:
    getSelectedColumnCount in interface TableColumnModel

### addColumnModelListener

    public void addColumnModelListener(TableColumnModelListener x)

  Specified by:
    addColumnModelListener in interface TableColumnModel

### removeColumnModelListener

    public void removeColumnModelListener(TableColumnModelListener x)

  Specified by:
    removeColumnModelListener in interface TableColumnModel

### fireColumnAdded

    protected void fireColumnAdded(TableColumnModelEvent e)

### fireColumnRemoved

    protected void fireColumnRemoved(TableColumnModelEvent e)

### fireColumnMoved

    protected void fireColumnMoved(TableColumnModelEvent e)

### fireColumnSelectionChanged

    protected void fireColumnSelectionChanged(ListSelectionEvent e)

### fireColumnMarginChanged

    protected void fireColumnMarginChanged()

### propertyChange

    public void propertyChange(java.beans.PropertyChangeEvent evt)

  Specified by:
    propertyChange in interface java.beans.PropertyChangeListener

### valueChanged

    public void valueChanged(ListSelectionEvent e)

  Specified by:
    valueChanged in interface ListSelectionListener

### createSelectionModel

    protected ListSelectionModel createSelectionModel()

### recalcWidthCache

    protected void recalcWidthCache()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.