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


Java TableColumnModel.removeColumn方法代码示例

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


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

示例1: createDefaultColumnsFromModel

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
@Override
public void createDefaultColumnsFromModel() {
    TableModel m = getModel();
    if( m != null ) {
        // Remove any current columns
        TableColumnModel cm = getColumnModel();
        while( cm.getColumnCount() > 0 ) {
            cm.removeColumn( cm.getColumn(0) );
 }

        // Create new columns from the data model info
        for( int i=0; i<m.getColumnCount(); i++ ) {
            TableColumn newColumn = new MyTableColumn(i);
            if( i == TaskListModel.COL_LOCATION )
                newColumn.setCellRenderer( new LeftDotRenderer() );
            else if( i != TaskListModel.COL_GROUP )
                newColumn.setCellRenderer( new TooltipRenderer() );
            addColumn(newColumn);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:TaskListTable.java

示例2: 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

示例3: deletecols

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
/**
 * deletes all selected columns if it is not present in the <code>exp</code>
 * List
 *
 * @param table the table to DELETE columns
 * @param exp columns to avoid deleting
 * @see #deletecol(javax.swing.JTable, int)
 */
static void deletecols(JTable table, int[] exp) {
    Integer[] selcols;
    try {
        TableColumnModel tcm = table.getColumnModel();
        selcols = ArrayUtils.toObject(table.getSelectedColumns());
        Arrays.sort(selcols, Collections.reverseOrder());
        List<Integer> explist = Ints.asList(exp);
        for (int i : selcols) {
            if (!explist.contains(i)) {
                tcm.removeColumn(tcm.getColumn(i));
            }
        }

    } catch (Exception e) {
        Logger.getLogger(JtableUtils.class.getName()).log(Level.SEVERE, null, e);
    }

}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:27,代码来源:JtableUtils.java

示例4: tableChanged

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
/***
 * Intercept changes to model so we can re-add our columns
 * @param e the table event
 */
@Override
public void tableChanged(TableModelEvent e)
{
	if (e == null || e.getFirstRow() == TableModelEvent.HEADER_ROW)
	{
		TableColumnModel tcm = getColumnModel();
		TableModel m = getModel();
		
		if (m != null)
		{
			// Remove any current columns
			while (tcm.getColumnCount() > 0) {
				tcm.removeColumn(tcm.getColumn(0));
			}

			// Create new columns from the data model info
			for (int ii = startModelColumn; ii < m.getColumnCount() && ii < endModelColumn; ii++) {
				TableColumn newColumn = new TableColumn(ii);
				addColumn(newColumn);
			}
		}
	}
	
	super.tableChanged(e);
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:30,代码来源:TableBase.java

示例5: testRemoveNodeColumn

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
public void testRemoveNodeColumn() throws InterruptedException, IllegalAccessException, InvocationTargetException {

        final TableColumnModel model = view.getOutline().getColumnModel();
        model.removeColumn(model.getColumn(0));
        assertEquals("One column visible", 1, model.getColumnCount());

        component.addNotify();
        final Node n0 = rootNode.getChildren().getNodeAt(0);

        rootNode.getChildren().remove(new Node[] { n0});
        assertEquals("One column visible after remove", 1, model.getColumnCount());
        rootNode.getChildren().add(new Node[] { n0});
        assertEquals("One column visible after add", 1, model.getColumnCount());
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:OutlineViewOrderingTest.java

示例6: createDefaultColumnsFromModel

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
@Override
public void createDefaultColumnsFromModel() {
	TableModel m = getModel();
	if (m != null) {
		// Remove any current columns
		TableColumnModel cm = getColumnModel();
		while (cm.getColumnCount() > 0) {
			cm.removeColumn(cm.getColumn(0));
		}

		// Create one column only
		TableColumn newColumn = new TableColumn(0);
		addColumn(newColumn);
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:16,代码来源:RowHeader.java

示例7: 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

示例8: 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

示例9: initDisplay

import javax.swing.table.TableColumnModel; //导入方法依赖的package包/类
void initDisplay() {

	tm = new SurveyPlannerTableModel (new Object[]{ "Line Number",
											 "Start Latitude",
									         "Start Longitude",
									         "Start Depth",
										     "End Latitude",
										     "End Longitude",
										     "End Depth",
										     "Km Cumulative Distance",
										     "Hrs Duration",
										     "surveyLine"}, surveyLines.size(), sp);
	
	table = new JTable(tm);
	
	//use the surveyLine column to keep track of the 
	//surveyLine object associated with that row,
	//but keep the column hidden
	TableColumnModel tcm = table.getColumnModel();
	slCol = tm.getSurveyLineColumn();
	if (slCol != 999) {
		tcm.removeColumn(tcm.getColumn(slCol));
	}
	
	tableSP = new JScrollPane(table);

	panel = new JPanel( new BorderLayout() ); // bottom panel
	panel.add( tableSP, "Center" );
	
	JPanel buttons = new JPanel( new GridLayout(0, 1) );
	addRowB = new JButton("Add Row");
	addRowB.setActionCommand("add");
	addRowB.addActionListener( this );
	buttons.add( addRowB );
	
	deleteRowB = new JButton("Delete Row(s)");
	deleteRowB.setActionCommand("delete");
	deleteRowB.addActionListener( this );
	buttons.add( deleteRowB );

	saveB = new JButton("Save");
	saveB.addActionListener(this);
	buttons.add(saveB);
	
	panel.add( buttons, "East" );

}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:48,代码来源:SurveyPlannerDataDisplay.java


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