当前位置: 首页>>代码示例>>Java>>正文


Java TableColumn.getModelIndex方法代码示例

本文整理汇总了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));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:PropertiesTableModel.java

示例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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ProfilerColumnModel.java

示例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());
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ProfilerColumnModel.java

示例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);
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:29,代码来源:MatrixPropertyTable.java

示例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);
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ProfilerColumnModel.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ProfilerColumnModel.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ProfilerColumnModel.java

示例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));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ThreadsPanel.java

示例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();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:14,代码来源:EditableTableHeaderColumn.java

示例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);
    }
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:14,代码来源:TableColumnSettings.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:DetailsTable.java

示例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 );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:TaskListTable.java

示例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();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:ProfilerTable.java

示例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 );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:UnitTable.java


注:本文中的javax.swing.table.TableColumn.getModelIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。