本文整理汇总了Java中javax.swing.table.TableColumn.getModelIndex方法的典型用法代码示例。如果您正苦于以下问题:Java TableColumn.getModelIndex方法的具体用法?Java TableColumn.getModelIndex怎么用?Java TableColumn.getModelIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.TableColumn
的用法示例。
在下文中一共展示了TableColumn.getModelIndex方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fireTableColumnChanged
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
/** Fires a TableModelEvent - change of one column */
public void fireTableColumnChanged(int index) {
int columnModelIndex = index;
// reset the header value as well
Object list[] = listenerList.getListenerList();
for (int i = 0; i < list.length; i++) {
if (list[i] instanceof JTable) {
JTable jt = (JTable)list[i];
try {
TableColumn column = jt.getColumnModel().getColumn(index);
columnModelIndex = column.getModelIndex();
column.setHeaderValue(jt.getModel().getColumnName(columnModelIndex));
} catch (ArrayIndexOutOfBoundsException abe) {
// only catch exception
}
jt.getTableHeader().repaint();
}
}
fireTableChanged(new TableModelEvent(this, 0, getRowCount() - 1, columnModelIndex));
}
示例2: showColumn
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
void showColumn(TableColumn column, ProfilerTable table) {
column.setMaxWidth(Integer.MAX_VALUE);
Integer width = hiddenColumnWidths.remove(column.getModelIndex());
column.setWidth(width != null ? width.intValue() :
getDefaultColumnWidth(column.getModelIndex()));
column.setMinWidth(minColumnWidth);
int toResizeIndex = getFitWidthColumn();
if (column.getModelIndex() == toResizeIndex) {
Enumeration<TableColumn> columns = getColumns();
while (columns.hasMoreElements()) {
TableColumn col = columns.nextElement();
int index = col.getModelIndex();
if (col.getModelIndex() != toResizeIndex && isColumnVisible(col))
col.setWidth(getDefaultColumnWidth(index));
}
table.doLayout();
}
}
示例3: hideColumn
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
void hideColumn(TableColumn column, ProfilerTable table) {
hiddenColumnWidths.put(column.getModelIndex(), column.getWidth());
column.setMinWidth(0);
column.setMaxWidth(0);
int selected = table.getSelectedColumn();
if (selected != -1 && getColumn(selected).equals(column)) {
int newSelected = getPreviousVisibleColumn(selected);
getSelectionModel().setSelectionInterval(newSelected, newSelected);
}
if (table.isSortable()) {
ProfilerRowSorter sorter = table._getRowSorter();
int sortColumn = sorter.getSortColumn();
if (sortColumn == column.getModelIndex()) {
int newSortColumn = table.convertColumnIndexToView(sortColumn);
newSortColumn = getPreviousVisibleColumn(newSortColumn);
sorter.setSortColumn(getColumn(newSortColumn).getModelIndex());
}
}
}
示例4: 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);
}
}
}
示例5: addColumn
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
public void addColumn(final TableColumn column) {
super.addColumn(column);
final int index = column.getModelIndex();
column.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (PROP_COLUMN_WIDTH.equals(evt.getPropertyName())) {
int oldWidth = ((Integer)evt.getOldValue()).intValue();
int newWidth = ((Integer)evt.getNewValue()).intValue();
fireColumnWidthChanged(index, oldWidth, newWidth);
}
}
});
}
示例6: setDefaultColumnWidth
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
void setDefaultColumnWidth(int width) {
defaultColumnWidth = width;
Enumeration<TableColumn> columns = getColumns();
while (columns.hasMoreElements()) {
TableColumn column = columns.nextElement();
int index = column.getModelIndex();
if (defaultColumnWidths == null || defaultColumnWidths.get(index) == null)
if (index != fitWidthColumn) column.setWidth(width);
}
}
示例7: getModelColumn
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
private TableColumn getModelColumn(int modelIndex) {
Enumeration<TableColumn> columns = getColumns();
while (columns.hasMoreElements()) {
TableColumn column = columns.nextElement();
if (column.getModelIndex() == modelIndex) return column;
}
return null;
}
示例8: repaintTimeline
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
private void repaintTimeline() {
JTableHeader header = threadsTable.getTableHeader();
TableColumn draggedColumn = header.getDraggedColumn();
if (draggedColumn != null && draggedColumn.getModelIndex() == 2) {
header.repaint();
} else {
int _column = threadsTable.convertColumnIndexToView(2);
header.repaint(header.getHeaderRect(_column));
}
}
示例9: copyValues
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
public void copyValues(TableColumn base) {
modelIndex = base.getModelIndex();
identifier = base.getIdentifier();
width = base.getWidth();
minWidth = base.getMinWidth();
setPreferredWidth(base.getPreferredWidth());
maxWidth = base.getMaxWidth();
headerRenderer = base.getHeaderRenderer();
headerValue = base.getHeaderValue();
cellRenderer = base.getCellRenderer();
cellEditor = base.getCellEditor();
isResizable = base.getResizable();
}
示例10: saveSettings
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
private void saveSettings() {
TableColumnModel columnModel = table.getColumnModel();
prefs.putInt(id + "-visible-column-count", columnModel.getColumnCount());
for (int i = 0; i < columnModel.getColumnCount(); i++) {
TableColumn col = columnModel.getColumn(i);
int idx = col.getModelIndex();
int width = col.getWidth();
prefs.putInt(id + "-column-width-" + idx, width);
prefs.putInt(id + "-column-order-" + i, idx);
}
}
示例11: addColumn
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
public void addColumn(TableColumn aColumn) {
super.addColumn(aColumn);
if (aColumn.getModelIndex() == 0 || aColumn.getModelIndex() == 1)
updateColumns(true);
}
示例12: setDraggedColumn
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
@Override
public void setDraggedColumn( TableColumn aColumn ) {
if( null != aColumn && aColumn.getModelIndex() == 0 )
return; //don't allow the first column to be dragged
super.setDraggedColumn( aColumn );
}
示例13: doLayout
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
public void doLayout() {
ProfilerColumnModel cModel = _getColumnModel();
JTableHeader header = getTableHeader();
TableColumn res = header == null ? null : header.getResizingColumn();
if (res != null) {
// Resizing column
int delta = getWidth() - cModel.getTotalColumnWidth();
TableColumn next = cModel.getNextVisibleColumn(res);
if (res == next) {
res.setWidth(res.getWidth() + delta);
} else {
next.setWidth(next.getWidth() + delta);
}
} else {
// Resizing table
int toResizeIndex = cModel.getFitWidthColumn();
if (toResizeIndex == -1) {
super.doLayout();
} else {
Enumeration<TableColumn> columns = cModel.getColumns();
TableColumn toResizeColumn = null;
int columnsWidth = 0;
while (columns.hasMoreElements()) {
TableColumn column = columns.nextElement();
if (column.getModelIndex() == toResizeIndex) {
if (!cModel.isColumnVisible(column)) {
super.doLayout();
return;
}
toResizeColumn = column;
} else {
columnsWidth += column.getWidth();
}
}
if (toResizeColumn != null) toResizeColumn.setWidth(getWidth() - columnsWidth);
// instead of super.doLayout()
layout();
}
}
}
示例14: setDraggedColumn
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
@Override
public void setDraggedColumn ( TableColumn aColumn ) {
if( null != aColumn && aColumn.getModelIndex () == 0 )
return; //don't allow the first column to be dragged
super.setDraggedColumn ( aColumn );
}