|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.table.DefaultTableColumnModel
be.ac.ulg.montefiore.run.totem.visualtopo.guiComponents.domainTables.XTableColumnModel
public class XTableColumnModel
XTableColumnModel
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()
There are overloaded versions of these methods that take a parameter onlyVisible
which let's
you specify wether you want invisible columns taken into account.
DefaultTableColumnModel
,
Serialized FormField Summary | |
---|---|
protected java.util.Vector |
allTableColumns
Array of TableColumn objects in this model. |
Fields inherited from class javax.swing.table.DefaultTableColumnModel |
---|
changeEvent, columnMargin, columnSelectionAllowed, listenerList, selectionModel, tableColumns, totalColumnWidth |
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)
Returns 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 the first column whose identifier equals identifier . |
java.util.Enumeration |
getColumns(boolean onlyVisible)
Returns an Enumeration of all the columns in the model. |
boolean |
isColumnVisible(javax.swing.table.TableColumn aColumn)
Checks wether the specified column is currently visible. |
void |
moveColumn(int oldIndex,
int newIndex)
Moves the column from oldIndex to newIndex . |
void |
removeColumn(javax.swing.table.TableColumn column)
Removes column from this column model. |
void |
setAllColumnsVisible()
Makes all columns in this model visible |
void |
setColumnVisible(javax.swing.table.TableColumn column,
boolean visible)
Sets the visibility of the specified TableColumn. |
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
Method Detail |
---|
public void setColumnVisible(javax.swing.table.TableColumn column, boolean visible)
aColumn
- the column to show/hidevisible
- its new visibility statuspublic void setAllColumnsVisible()
public javax.swing.table.TableColumn getColumnByModelIndex(int modelColumnIndex)
modelColumnIndex
to the TableColumn object.
There may me 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.
modelColumnIndex
- index of column in table model
public boolean isColumnVisible(javax.swing.table.TableColumn aColumn)
aColumn
- column to check
public void addColumn(javax.swing.table.TableColumn column)
column
to the right of exisiting columns.
Posts columnAdded
event.
addColumn
in interface javax.swing.table.TableColumnModel
addColumn
in class javax.swing.table.DefaultTableColumnModel
column
- The column to be added
java.lang.IllegalArgumentException
- if column
is null
removeColumn(javax.swing.table.TableColumn)
public void removeColumn(javax.swing.table.TableColumn column)
column
from this column model.
Posts columnRemoved
event.
Will do nothing if the column is not in this model.
removeColumn
in interface javax.swing.table.TableColumnModel
removeColumn
in class javax.swing.table.DefaultTableColumnModel
column
- the column to be addedaddColumn(javax.swing.table.TableColumn)
public void moveColumn(int oldIndex, int newIndex)
oldIndex
to newIndex
.
Posts columnMoved
event.
Will not move any columns if oldIndex
equals newIndex
.
moveColumn
in interface javax.swing.table.TableColumnModel
moveColumn
in class javax.swing.table.DefaultTableColumnModel
oldIndex
- index of column to be movednewIndex
- new index of the column
java.lang.IllegalArgumentException
- if either oldIndex
or
newIndex
are not in [0, getColumnCount() - 1]public int getColumnCount(boolean onlyVisible)
onlyVisible
- if set only visible columns will be counted
tableColumns
arraygetColumns(boolean)
public java.util.Enumeration getColumns(boolean onlyVisible)
Enumeration
of all the columns in the model.
onlyVisible
- if set all invisible columns will be missing from the enumeration.
Enumeration
of the columns in the modelpublic int getColumnIndex(java.lang.Object identifier, boolean onlyVisible)
identifier
.
Position is the the index in all visible columns if onlyVisible
is true or
else the index in all columns.
identifier
- the identifier object to search foronlyVisible
- if set searches only visible columns
identifier
java.lang.IllegalArgumentException
- if identifier
is null
, or if no
TableColumn
has this
identifier
getColumn(int, boolean)
public javax.swing.table.TableColumn getColumn(int columnIndex, boolean onlyVisible)
TableColumn
object for the column
at columnIndex
.
columnIndex
- the index of the column desiredonlyVisible
- if set columnIndex is meant to be relative to all visible columns only
else it is the index in all columns
TableColumn
object for the column
at columnIndex
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |