|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
public interface TableColumnModel
定义了适合用于 JTable 的表列模型对象的要求。
DefaultTableColumnModel| 方法摘要 | |
|---|---|
void |
addColumn(TableColumn aColumn)
将 aColumn 追加到 tableColumns 数组的结尾。 |
void |
addColumnModelListener(TableColumnModelListener x)
为表列模型事件添加侦听器。 |
TableColumn |
getColumn(int columnIndex)
返回 columnIndex 位置列的 TableColumn 对象。 |
int |
getColumnCount()
返回该模型中的列数。 |
int |
getColumnIndex(Object columnIdentifier)
返回该表中首列的索引,使用 equals 进行比较时,该列的标识符等于 identifier。 |
int |
getColumnIndexAtX(int xPosition)
返回位于该水平点 xPosition 位置列的索引;如果该点位于任何列边界外,则返回 -1。 |
int |
getColumnMargin()
返回每列中单元格之间的宽度。 |
Enumeration<TableColumn> |
getColumns()
返回该模型中所有列的 Enumeration。 |
boolean |
getColumnSelectionAllowed()
如果可以选择列,则返回 true。 |
int |
getSelectedColumnCount()
返回选定的列数。 |
int[] |
getSelectedColumns()
返回所有选定列的索引数组。 |
ListSelectionModel |
getSelectionModel()
返回当前的选择模型。 |
int |
getTotalColumnWidth()
返回所有列的总宽度。 |
void |
moveColumn(int columnIndex,
int newIndex)
将 columnIndex 位置的列及其头移至 newIndex。 |
void |
removeColumn(TableColumn column)
从 tableColumns 数组中删除 TableColumn column。 |
void |
removeColumnModelListener(TableColumnModelListener x)
移除表列模型事件的侦听器。 |
void |
setColumnMargin(int newMargin)
将 TableColumn 的列空白设置为 newMargin。 |
void |
setColumnSelectionAllowed(boolean flag)
设置是否可以选择此模型中的列。 |
void |
setSelectionModel(ListSelectionModel newModel)
设置选择模型。 |
| 方法详细信息 |
|---|
void addColumn(TableColumn aColumn)
aColumn 追加到 tableColumns 数组的结尾。此方法向其侦听器发送一个 columnAdded 事件。
aColumn - 要添加的 TableColumnremoveColumn(javax.swing.table.TableColumn)void removeColumn(TableColumn column)
tableColumns 数组中删除 TableColumn column。如果 column 不处于该表各列的列表中,则此方法不执行任何操作。此方法向其侦听器发送一个 columnRemoved 事件。
column - 要移除的 TableColumnaddColumn(javax.swing.table.TableColumn)
void moveColumn(int columnIndex,
int newIndex)
columnIndex 位置的列及其头移至 newIndex。原位于 columnIndex 位置的列现在将在 newIndex 处找到。将原位于 newIndex 位置的列向左或向右移动以留出空间。如果 columnIndex 等于 newIndex,则不移动任何列。此方法向其侦听器发送一个 columnMoved 事件。
columnIndex - 要移动的列的索引newIndex - 该列新位置的索引
IllegalArgumentException - 如果 columnIndex 或 newIndex 不在有效范围内void setColumnMargin(int newMargin)
TableColumn 的列空白设置为 newMargin。此方法向其侦听器发送一个 columnMarginChanged 事件。
newMargin - 新列空白的宽度,以像素为单位getColumnMargin()int getColumnCount()
Enumeration<TableColumn> getColumns()
Enumeration。
Enumerationint getColumnIndex(Object columnIdentifier)
equals 进行比较时,该列的标识符等于 identifier。
columnIdentifier - 标识符对象
identifier
IllegalArgumentException - 如果 identifier 为 null,或者没有 TableColumn 具有此 identifiergetColumn(int)TableColumn getColumn(int columnIndex)
columnIndex 位置列的 TableColumn 对象。
columnIndex - 所需列的索引
columnIndex 位置列的 TableColumn 对象int getColumnMargin()
int getColumnIndexAtX(int xPosition)
xPosition 位置列的索引;如果该点位于任何列边界外,则返回 -1。
在维护 Swing 的可分离模型架构的过程中,TableColumnModel 并不了解表的各列实际出现在屏幕上的方式。列的虚拟展示由使用此模型(通常是 JTable)的 view/controller 对象负责。view/controller 不必从左到右按顺序显示这些列。例如,为了适应语言环境的优先选择,可以从右到左显示各列,或者可能根据用户的请求隐藏某些列。因为该模型不了解各列在屏幕上的排列方式,所以不应将给定的 xPosition 考虑为 2D 图形空间中的坐标。相反,应将其考虑为从模型中第一列开始的宽度。如果要求 2D 空间中给定 X 坐标的列索引,则可以使用 JTable.columnAtPoint。
JTable.columnAtPoint(java.awt.Point)int getTotalColumnWidth()
void setColumnSelectionAllowed(boolean flag)
flag - 如果可以选择列,则为 true;否则为 falsegetColumnSelectionAllowed()boolean getColumnSelectionAllowed()
setColumnSelectionAllowed(boolean)int[] getSelectedColumns()
int getSelectedColumnCount()
void setSelectionModel(ListSelectionModel newModel)
newModel - ListSelectionModel 对象getSelectionModel()ListSelectionModel getSelectionModel()
ListSelectionModel 对象setSelectionModel(javax.swing.ListSelectionModel)void addColumnModelListener(TableColumnModelListener x)
x - TableColumnModelListener 对象void removeColumnModelListener(TableColumnModelListener x)
x - TableColumnModelListener 对象
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。