public class VisibilityTableColumnModel extends javax.swing.table.DefaultTableColumnModel implements IVisibilityTableColumnModel
VisibilityTableColumnModel extends the DefaultTableColumnModel .
 It provides a comfortable way to hide/show columns.
 Columns keep their positions when hidden and shown again.
 In order to work with JTable it cannot add any events to TableColumnModelListener.
 Therefore hiding a column will result in columnRemoved event and showing it
 again will notify listeners of a columnAdded, and possibly a columnMoved event.
 For the same reason the following methods still deal with visible columns only:
 getColumnCount(), getColumns(), getColumnIndex(), getColumn()
 If you want to take invisible column into account use:
 getAllColumnCount(), getAllColumns(), getAllColumnIndex(), getAllColumn()DefaultTableColumnModel, 
Serialized Form| Modifier and Type | Field and Description | 
|---|---|
| protected java.util.Vector | allTableColumnsArray of TableColumn objects in this model. | 
| protected java.util.Vector | tableColumnsFixedArray of TableColumn objects that
 cannot change the visibility. | 
| Constructor and Description | 
|---|
| VisibilityTableColumnModel()Creates an extended table column model. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addColumn(javax.swing.table.TableColumn column)Appends  aColumnto the end of thetableColumnsarray. | 
| void | addMouseListener(javax.swing.JTable table)Helper method that adds a mouselistener to the header of a given  JTable. | 
| javax.swing.table.TableColumn | getAllColumn(int columnIndex)Returns the  TableColumnobject for the column atcolumnIndex. | 
| int | getAllColumnCount()Returns the number of columns in the model. | 
| int | getAllColumnIndex(java.lang.Object identifier)Returns the index of the first column in the table
 whose identifier is equal to  identifier,
 when compared usingequals. | 
| java.util.Enumeration | getAllColumns()Returns an  Enumerationof all the columns in the model. | 
| boolean | isColumnChangeable(javax.swing.table.TableColumn column)Checks whether the specified column can change visibility. | 
| boolean | isColumnVisible(javax.swing.table.TableColumn aColumn)Checks whether the specified column is currently visible. | 
| void | moveColumn(int columnIndex,
          int newIndex)Moves the column and its header at  columnIndextonewIndex. | 
| void | removeColumn(javax.swing.table.TableColumn column)Deletes the  TableColumncolumnfrom thetableColumnsarray. | 
| void | setAllColumnsVisible()Makes all columns in this model visible | 
| void | setColumnChangeable(javax.swing.table.TableColumn column,
                   boolean changeable)Sets whether this column can change visibility. | 
| void | setColumnVisible(javax.swing.table.TableColumn column,
                boolean visible)Sets the visibility of the specified TableColumn. | 
addColumnModelListener, createSelectionModel, fireColumnAdded, fireColumnMarginChanged, fireColumnMoved, fireColumnRemoved, fireColumnSelectionChanged, getColumn, getColumnCount, getColumnIndex, getColumnIndexAtX, getColumnMargin, getColumnModelListeners, getColumns, getColumnSelectionAllowed, getListeners, getSelectedColumnCount, getSelectedColumns, getSelectionModel, getTotalColumnWidth, propertyChange, recalcWidthCache, removeColumnModelListener, setColumnMargin, setColumnSelectionAllowed, setSelectionModel, valueChangedprotected java.util.Vector allTableColumns
protected java.util.Vector tableColumnsFixed
public VisibilityTableColumnModel()
public void addColumn(javax.swing.table.TableColumn column)
aColumn to the end of the
  tableColumns array.
  This method posts a columnAdded
  event to its listeners.addColumn in interface javax.swing.table.TableColumnModeladdColumn in class javax.swing.table.DefaultTableColumnModelcolumn - the TableColumn to be addedDefaultTableColumnModel.addColumn(javax.swing.table.TableColumn)public void removeColumn(javax.swing.table.TableColumn column)
TableColumn column from the
  tableColumns array.  This method will do nothing if
  column is not in the table's column list.
  This method posts a columnRemoved
  event to its listeners.removeColumn in interface javax.swing.table.TableColumnModelremoveColumn in class javax.swing.table.DefaultTableColumnModelcolumn - the TableColumn to be removedDefaultTableColumnModel.removeColumn(javax.swing.table.TableColumn)public void moveColumn(int columnIndex,
                       int newIndex)
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
 posts a columnMoved event to its listeners.moveColumn in interface javax.swing.table.TableColumnModelmoveColumn in class javax.swing.table.DefaultTableColumnModelcolumnIndex - the index of column to be movednewIndex - index of the column's new locationjava.lang.IllegalArgumentException - if columnIndex or
                                          newIndex
                                          are not in the valid rangeDefaultTableColumnModel.moveColumn(int, int)public int getAllColumnCount()
getAllColumnCount in interface IVisibilityTableColumnModelpublic java.util.Enumeration getAllColumns()
Enumeration of all the columns in the model.
 getAllColumns in interface IVisibilityTableColumnModelEnumeration of all the columns in the modelpublic int getAllColumnIndex(java.lang.Object identifier)
identifier,
 when compared using equals.
 getAllColumnIndex in interface IVisibilityTableColumnModelidentifier - the identifier objectidentifierjava.lang.IllegalArgumentException - if identifier
                                is null, or no
                                TableColumn has this
                                identifiergetAllColumn(int)public javax.swing.table.TableColumn getAllColumn(int columnIndex)
TableColumn object for the column at
 columnIndex.
 getAllColumn in interface IVisibilityTableColumnModelcolumnIndex - the index of the desired columnTableColumn object for
                                the column at columnIndexpublic void setColumnVisible(javax.swing.table.TableColumn column,
                             boolean visible)
columnAdded or columnRemoved
  event to its listeners.setColumnVisible in interface IVisibilityTableColumnModelcolumn - the TableColumnvisible - its new visibility statuspublic void setAllColumnsVisible()
setAllColumnsVisible in interface IVisibilityTableColumnModelisColumnVisible(javax.swing.table.TableColumn), 
setColumnVisible(javax.swing.table.TableColumn, boolean)public boolean isColumnVisible(javax.swing.table.TableColumn aColumn)
isColumnVisible in interface IVisibilityTableColumnModelaColumn - column to checksetAllColumnsVisible(), 
setColumnVisible(javax.swing.table.TableColumn, boolean)public void setColumnChangeable(javax.swing.table.TableColumn column,
                                boolean changeable)
setColumnChangeable in interface IVisibilityTableColumnModelcolumn - the TableColumnchangeable - if true, changing visibility is allowed;
                      otherwise falsepublic boolean isColumnChangeable(javax.swing.table.TableColumn column)
isColumnChangeable in interface IVisibilityTableColumnModelcolumn - column to checkpublic void addMouseListener(javax.swing.JTable table)
JTable.
 On right click a popup menu will appear to change the visibility of
 the columns in the jtabletable - the JTable to add the mouselistener to its header