當前位置: 首頁>>代碼示例>>Java>>正文


Java TableColumnModel.addColumn方法代碼示例

本文整理匯總了Java中javax.swing.table.TableColumnModel.addColumn方法的典型用法代碼示例。如果您正苦於以下問題:Java TableColumnModel.addColumn方法的具體用法?Java TableColumnModel.addColumn怎麽用?Java TableColumnModel.addColumn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.table.TableColumnModel的用法示例。


在下文中一共展示了TableColumnModel.addColumn方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: recreateTableColumn

import javax.swing.table.TableColumnModel; //導入方法依賴的package包/類
protected void recreateTableColumn(TableColumnModel columnModel) {
	int n = columnModel.getColumnCount();
	EditableTableHeaderColumn[] newCols = new EditableTableHeaderColumn[n];
	TableColumn[] oldCols = new TableColumn[n];
	for (int i = 0; i < n; i++) {
		oldCols[i] = columnModel.getColumn(i);
		newCols[i] = new EditableTableHeaderColumn(i);
		newCols[i].copyValues(oldCols[i]);
	}
	for (int i = 0; i < n; i++) {
		columnModel.removeColumn(oldCols[i]);
	}
	for (int i = 0; i < n; i++) {
		columnModel.addColumn(newCols[i]);
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:17,代碼來源:EditableTableHeader.java

示例2: getJTableOptions

import javax.swing.table.TableColumnModel; //導入方法依賴的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 String cNames[] = new String[table.getColumnCount()];
    final Object cols[] = new Object[table.getColumnCount()];

    for (int i = 0; i < cNames.length; i++) {
        cNames[i] = table.getColumnName(i);
        cols[i] = table.getColumnModel().getColumn(i);
    }

    for (final String element : cNames) {
        final int width = getInteger(name + "_col_" + element + "_width",
                table.getColumn(element).getWidth(), properties);
        table.getColumn(element).setPreferredWidth(width);
    }

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

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

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

}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:37,代碼來源:Options.java

示例3: getJTableOptions

import javax.swing.table.TableColumnModel; //導入方法依賴的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.table.TableColumnModel.addColumn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。