|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.table.DefaultTableColumnModel
edu.northwestern.at.utils.swing.XTableColumnModel
public class XTableColumnModel
XTableColumnModel extends DefaultTableColumnModel with methods to hide and unhide columns.
Columns retain their relative positions when hidden and unhidden.
Hiding a column fires a columnRemoved event and unhiding a column fires a columnAdded event, and possibly a columnMoved event as well.
The following methods still deal with visible columns only: getColumnCount(), getColumns(), getColumnIndex(), getColumn() . Use the overloaded versions of these methods that take a parameter onlyVisible if you wish to account for hidden columns as well.
Field Summary | |
---|---|
protected java.util.Vector |
allTableColumns
Holds all the column objects, regardless of visibility. |
Fields inherited from class javax.swing.table.DefaultTableColumnModel |
---|
changeEvent, columnMargin, columnSelectionAllowed, listenerList, selectionModel, tableColumns, totalColumnWidth |
Constructor Summary | |
---|---|
XTableColumnModel()
Create an extended table column model. |
Method Summary | |
---|---|
void |
addColumn(javax.swing.table.TableColumn column)
Append column to the right of exisiting columns. |
javax.swing.table.TableColumn |
getColumn(int columnIndex,
boolean onlyVisible)
Return the TableColumn object for the column at columnIndex. |
javax.swing.table.TableColumn |
getColumnByModelIndex(int modelColumnIndex)
Maps the index of the column in the table model at modelColumnIndex to the TableColumn object. |
int |
getColumnCount(boolean onlyVisible)
Returns the total number of columns in this model. |
int |
getColumnIndex(java.lang.Object identifier,
boolean onlyVisible)
Returns the position of first column matching specified identifier. |
java.util.Enumeration |
getColumns(boolean onlyVisible)
Returns an enumeration of all the columns in the model. |
boolean |
isColumnVisible(int columnIndex)
Checks whether a specified column is currently visible. |
boolean |
isColumnVisible(javax.swing.table.TableColumn column)
Checks whether a specified column is currently visible. |
void |
moveColumn(int oldIndex,
int newIndex)
Moves column. |
void |
removeColumn(javax.swing.table.TableColumn column)
Removes column from the column model. |
void |
setAllColumnsVisible()
Make all columns in this model visible. |
void |
setColumnVisible(int columnIndex,
boolean isVisible)
Sets the visibility of the specified table column by index. |
void |
setColumnVisible(javax.swing.table.TableColumn column,
boolean isVisible)
Sets the visibility of the specified table column. |
Methods inherited from class javax.swing.table.DefaultTableColumnModel |
---|
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, valueChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Vector allTableColumns
Constructor Detail |
---|
public XTableColumnModel()
Method Detail |
---|
public void setColumnVisible(javax.swing.table.TableColumn column, boolean isVisible)
column
- The column to hide/unhide.isVisible
- True to unhide the column, false to hide. public void setColumnVisible(int columnIndex, boolean isVisible)
columnIndex
- The inde of the column to hide/unhide.isVisible
- True to unhide the column, false to hide. public void setAllColumnsVisible()
public javax.swing.table.TableColumn getColumnByModelIndex(int modelColumnIndex)
modelColumnIndex
- Index of column in table model.
There may be multiple TableColumn objects showing the same model column, though this is uncommon.
This method will always return the first visible or else the first invisible column with the specified index.
public boolean isColumnVisible(javax.swing.table.TableColumn column)
column
- Column to check.
public boolean isColumnVisible(int columnIndex)
columnIndex
- Index of column to check.
public void addColumn(javax.swing.table.TableColumn column)
addColumn
in interface javax.swing.table.TableColumnModel
addColumn
in class javax.swing.table.DefaultTableColumnModel
column
- The column to add.
java.lang.IllegalArgumentException
- if column is null. public void removeColumn(javax.swing.table.TableColumn column)
removeColumn
in interface javax.swing.table.TableColumnModel
removeColumn
in class javax.swing.table.DefaultTableColumnModel
column
- Column to be removed. public void moveColumn(int oldIndex, int newIndex)
moveColumn
in interface javax.swing.table.TableColumnModel
moveColumn
in class javax.swing.table.DefaultTableColumnModel
oldIndex
- Index of column to move.newIndex
- New index for column.
java.lang.IllegalArgumentException
- if either oldIndex or newIndex are not in
[0, getColumnCount() - 1]. public int getColumnCount(boolean onlyVisible)
onlyVisible
- If true, only visible columns are counted.
public java.util.Enumeration getColumns(boolean onlyVisible)
onlyVisible
- If true, all invisible columns will be
excluded from the enumeration.
public int getColumnIndex(java.lang.Object identifier, boolean onlyVisible)
identifier
- Identifier object for which to search.onlyVisible
- True to search only visible columns.
java.lang.IllegalArgumentException
- if identifier is null or no column matches. public javax.swing.table.TableColumn getColumn(int columnIndex, boolean onlyVisible)
columnIndex
- Index of the desired column.onlyVisible
- If true, columnIndex is meant to be
relative to all visible columns only.
If false, it is the index in all columns.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |