Top Description Methods
javax.swing.table

public Interface TableColumnModel

Known Direct Implementers
javax.swing.table.DefaultTableColumnModel
Imports
java.util.Enumeration, javax.swing.event.ChangeEvent, javax.swing.event.*, javax.swing.*

Defines the requirements for a table column model object suitable for use with JTable.
Authors
Alan Chung, Philip Milne
See Also
DefaultTableColumnModel

Method Summary

Modifier and TypeMethod and Description
public void
addColumn(TableColumn
the TableColumn to be added
aColumn
)

Appends aColumn to the end of the tableColumns array.

public void
addColumnModelListener(TableColumnModelListener
a TableColumnModelListener object
x
)

Adds a listener for table column model events.

public TableColumn

Returns:

the TableColumn object for the column at columnIndex
getColumn
(int
the index of the desired column
columnIndex
)

Returns the TableColumn object for the column at columnIndex.

public int

Returns:

the number of columns in the model
getColumnCount
()

Returns the number of columns in the model.

public int

Returns:

the index of the first table column whose identifier is equal to identifier
getColumnIndex
(Object
the identifier object
columnIdentifier
)

Returns the index of the first column in the table whose identifier is equal to identifier, when compared using equals.

public int

Returns:

the index of the column; or -1 if no column is found
getColumnIndexAtX
(int
width from the start of the first column in the model.
xPosition
)

Returns the index of the column that lies on the horizontal point, xPosition; or -1 if it lies outside the any of the column's bounds.

public int

Returns:

the margin, in pixels, between the cells
getColumnMargin
()

Returns the width between the cells in each column.

public Enumeration<TableColumn>

Returns:

an Enumeration of all the columns in the model
getColumns
()

Returns an Enumeration of all the columns in the model.

public boolean

Returns:

true if columns may be selected
getColumnSelectionAllowed
()

Returns true if columns may be selected.

public int

Returns:

the number of selected columns; or 0 if no columns are selected
getSelectedColumnCount
()

Returns the number of selected columns.

public int[]

Returns:

an array of integers containing the indices of all selected columns; or an empty array if nothing is selected
getSelectedColumns
()

Returns an array of indices of all selected columns.

public ListSelectionModel

Returns:

a ListSelectionModel object
getSelectionModel
()

Returns the current selection model.

public int

Returns:

the total computed width of all columns
getTotalColumnWidth
()

Returns the total width of all the columns.

public void
moveColumn(int
the index of column to be moved
columnIndex
,
int
index of the column's new location
newIndex
)

Moves the column and its header at columnIndex to newIndex.

public void
removeColumn(TableColumn
the TableColumn to be removed
column
)

Deletes the TableColumn column from the tableColumns array.

public void
removeColumnModelListener(TableColumnModelListener
a TableColumnModelListener object
x
)

Removes a listener for table column model events.

public void
setColumnMargin(int
the width, in pixels, of the new column margins
newMargin
)

Sets the TableColumn's column margin to newMargin.

public void
setColumnSelectionAllowed(boolean
true if columns may be selected; otherwise false
flag
)

Sets whether the columns in this model may be selected.

public void
setSelectionModel(ListSelectionModel
a ListSelectionModel object
newModel
)

Sets the selection model.

Method Detail

addColumnback to summary
public void addColumn(TableColumn aColumn)

Appends aColumn to the end of the tableColumns array. This method posts a columnAdded event to its listeners.

Parameters
aColumn:TableColumn

the TableColumn to be added

See Also
removeColumn
addColumnModelListenerback to summary
public void addColumnModelListener(TableColumnModelListener x)

Adds a listener for table column model events.

Parameters
x:TableColumnModelListener

a TableColumnModelListener object

getColumnback to summary
public TableColumn getColumn(int columnIndex)

Returns the TableColumn object for the column at columnIndex.

Parameters
columnIndex:int

the index of the desired column

Returns:TableColumn

the TableColumn object for the column at columnIndex

getColumnCountback to summary
public int getColumnCount()

Returns the number of columns in the model.

Returns:int

the number of columns in the model

getColumnIndexback to summary
public int getColumnIndex(Object columnIdentifier)

Returns the index of the first column in the table whose identifier is equal to identifier, when compared using equals.

Parameters
columnIdentifier:Object

the identifier object

Returns:int

the index of the first table column whose identifier is equal to identifier

Exceptions
IllegalArgumentException:
if identifier is null, or no TableColumn has this identifier
See Also
getColumn
getColumnIndexAtXback to summary
public int getColumnIndexAtX(int xPosition)

Returns the index of the column that lies on the horizontal point, xPosition; or -1 if it lies outside the any of the column's bounds. In keeping with Swing's separable model architecture, a TableColumnModel does not know how the table columns actually appear on screen. The visual presentation of the columns is the responsibility of the view/controller object using this model (typically JTable). The view/controller need not display the columns sequentially from left to right. For example, columns could be displayed from right to left to accommodate a locale preference or some columns might be hidden at the request of the user. Because the model does not know how the columns are laid out on screen, the given xPosition should not be considered to be a coordinate in 2D graphics space. Instead, it should be considered to be a width from the start of the first column in the model. If the column index for a given X coordinate in 2D space is required, JTable.columnAtPoint can be used instead.

Parameters
xPosition:int

width from the start of the first column in the model.

Returns:int

the index of the column; or -1 if no column is found

See Also
javax.swing.JTable#columnAtPoint
getColumnMarginback to summary
public int getColumnMargin()

Returns the width between the cells in each column.

Returns:int

the margin, in pixels, between the cells

getColumnsback to summary
public Enumeration<TableColumn> getColumns()

Returns an Enumeration of all the columns in the model.

Returns:Enumeration<TableColumn>

an Enumeration of all the columns in the model

getColumnSelectionAllowedback to summary
public boolean getColumnSelectionAllowed()

Returns true if columns may be selected.

Returns:boolean

true if columns may be selected

See Also
setColumnSelectionAllowed
getSelectedColumnCountback to summary
public int getSelectedColumnCount()

Returns the number of selected columns.

Returns:int

the number of selected columns; or 0 if no columns are selected

getSelectedColumnsback to summary
public int[] getSelectedColumns()

Returns an array of indices of all selected columns.

Returns:int[]

an array of integers containing the indices of all selected columns; or an empty array if nothing is selected

getSelectionModelback to summary
public ListSelectionModel getSelectionModel()

Returns the current selection model.

Returns:ListSelectionModel

a ListSelectionModel object

See Also
setSelectionModel
getTotalColumnWidthback to summary
public int getTotalColumnWidth()

Returns the total width of all the columns.

Returns:int

the total computed width of all columns

moveColumnback to summary
public void moveColumn(int columnIndex, int newIndex)

Moves the column and its header 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 posts a columnMoved event to its listeners.

Parameters
columnIndex:int

the index of column to be moved

newIndex:int

index of the column's new location

Exceptions
IllegalArgumentException:
if columnIndex or newIndex are not in the valid range
removeColumnback to summary
public void removeColumn(TableColumn column)

Deletes the 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.

Parameters
column:TableColumn

the TableColumn to be removed

See Also
addColumn
removeColumnModelListenerback to summary
public void removeColumnModelListener(TableColumnModelListener x)

Removes a listener for table column model events.

Parameters
x:TableColumnModelListener

a TableColumnModelListener object

setColumnMarginback to summary
public void setColumnMargin(int newMargin)

Sets the TableColumn's column margin to newMargin. This method posts a columnMarginChanged event to its listeners.

Parameters
newMargin:int

the width, in pixels, of the new column margins

See Also
getColumnMargin
setColumnSelectionAllowedback to summary
public void setColumnSelectionAllowed(boolean flag)

Sets whether the columns in this model may be selected.

Parameters
flag:boolean

true if columns may be selected; otherwise false

See Also
getColumnSelectionAllowed
setSelectionModelback to summary
public void setSelectionModel(ListSelectionModel newModel)

Sets the selection model.

Parameters
newModel:ListSelectionModel

a ListSelectionModel object

See Also
getSelectionModel