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


Java JTable.convertColumnIndexToView方法代码示例

本文整理汇总了Java中javax.swing.JTable.convertColumnIndexToView方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.convertColumnIndexToView方法的具体用法?Java JTable.convertColumnIndexToView怎么用?Java JTable.convertColumnIndexToView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTable的用法示例。


在下文中一共展示了JTable.convertColumnIndexToView方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getIcon

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Overridden to return an icon suitable to a sorted column, or null if the
 * column is unsorted. The icon for the primary sorted column is fully
 * opaque, and the opacity is reduced by a factor of
 * <code>alpha</code> for each subsequent sort index.
 *
 * @param table the <code>JTable</code>.
 * @param column the column index.
 * @return the sort icon with appropriate opacity, or null if the column is
 * unsorted.
 */
@Override
public Icon getIcon(JTable table, int column) {
    float computedAlpha = 1.0F;
    for (RowSorter.SortKey sortKey : table.getRowSorter().getSortKeys()) {
        if (table.convertColumnIndexToView(sortKey.getColumn()) == column) {
            switch (sortKey.getSortOrder()) {
                case ASCENDING:
                    return new AlphaIcon(UIManager.getIcon("Table.ascendingSortIcon"), computedAlpha);
                case DESCENDING:
                    return new AlphaIcon(UIManager.getIcon("Table.descendingSortIcon"), computedAlpha);
                    
                default:
                    // Just to remove unmatched case warning
            }
        }
        computedAlpha *= alpha;
    }
    return null;
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:31,代码来源:MultiColumnSortTableHeaderCellRenderer.java

示例2: getIcon

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Overloaded to return an icon suitable to the primary sorted column, or
 * null if the column is not the primary sort key.
 *
 * @param table the <code>JTable</code>.
 * @param column the column index.
 * @return the sort icon, or null if the column is unsorted.
 */
protected Icon getIcon(JTable table, int column) {
    SortKey sortKey = getSortKey(table, column);
    if (sortKey != null && table.convertColumnIndexToView(sortKey.getColumn()) == column) {
        switch (sortKey.getSortOrder()) {
            case ASCENDING:
                return UIManager.getIcon("Table.ascendingSortIcon");
            case DESCENDING:
                return UIManager.getIcon("Table.descendingSortIcon");
                
            default:
                // Just to remove unmatched case warning
        }
    }
    return null;
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:24,代码来源:DefaultTableHeaderCellRenderer.java

示例3: setJTableOptions

import javax.swing.JTable; //导入方法依赖的package包/类
public static void setJTableOptions(final String name, final JTable table,
                                    final Properties properties) {
    setInteger(name + "_col_count", table.getColumnCount(), properties);
    for (int i = 0; i < table.getColumnCount(); i++) {
        try {
            int index = table.convertColumnIndexToView(i);
            setInteger(name + "_col_" + i + "_width", table
                            .getColumnModel().getColumn(index).getWidth(),
                    properties);
            setInteger(name + "_col_" + i + "_index", index, properties);
        } catch (final Exception e) {

        }
    }
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:16,代码来源:Options.java

示例4: getJTableOptions

import javax.swing.JTable; //导入方法依赖的package包/类
public static void getJTableOptions(final String name, final JTable table,
                                    final Properties properties) {
    final Integer colCount = getObjectInteger(name + "_col_count",
            properties);
    if (colCount == null || colCount.intValue() != table.getColumnCount())
        return;
    final Object cols[] = new Object[table.getColumnCount()];

    for (int i = 0; i < colCount.intValue(); i++) {
        cols[i] = table.getColumnModel().getColumn(
                table.convertColumnIndexToView(i));
    }

    for (int i = 0; i < colCount.intValue(); i++) {
        try {
            int index = table.convertColumnIndexToView(i);
            final int width = getInteger(name + "_col_" + i + "_width",
                    table.getColumnModel().getColumn(index).getWidth(),
                    properties);
            table.getColumnModel().getColumn(index)
                    .setPreferredWidth(width);
        } catch (Exception e) {

        }
    }

    final TableColumnModel cm = table.getColumnModel();
    final int tci[] = new int[colCount.intValue()];
    for (int i = 0; i < colCount.intValue(); i++)
        cm.removeColumn((TableColumn) cols[i]);

    for (int i = 0; i < colCount.intValue(); i++) {
        tci[i] = getInteger(name + "_col_" + i + "_index", i, properties);
    }

    for (int i = 0; i < colCount.intValue(); i++)
        for (int j = 0; j < colCount.intValue(); j++)
            if (tci[j] == i)
                cm.addColumn((TableColumn) cols[j]);

}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:42,代码来源:Options.java


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