本文整理汇总了Java中javax.swing.table.TableColumn.setModelIndex方法的典型用法代码示例。如果您正苦于以下问题:Java TableColumn.setModelIndex方法的具体用法?Java TableColumn.setModelIndex怎么用?Java TableColumn.setModelIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.TableColumn
的用法示例。
在下文中一共展示了TableColumn.setModelIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeColumn
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
public void removeColumn(int index) {
TableColumn column = getColumnModel().getColumn(index);
int modelIndex = column.getModelIndex();
Vector modelData = model.getDataVector();
Vector columnIdentifiers = model.getColumnIdentifiers();
// remove the column from the table
removeColumn(column);
// remove the column header from the table model
columnIdentifiers.removeElementAt(modelIndex);
// remove the column data
for (int i = 0; i < modelData.size(); i++) {
Vector row = (Vector) modelData.get(i);
row.removeElementAt(modelIndex);
}
model.setDataVector(modelData, columnIdentifiers);
// correct the model indices in the TableColumn objects
Enumeration columns = getColumnModel().getColumns();
while (columns.hasMoreElements()) {
TableColumn currentColumn = (TableColumn) columns.nextElement();
if (currentColumn.getModelIndex() >= modelIndex) {
currentColumn.setModelIndex(currentColumn.getModelIndex() - 1);
}
}
}