當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。