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


Java JTable.getCellEditor方法代码示例

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


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

示例1: actionPerformed

import javax.swing.JTable; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent ae) {
    JTable jt = (JTable) ae.getSource();

    if (jt != null) {
        if (jt.isEditing()) {
            TableCellEditor tce = jt.getCellEditor();

            if (PropUtils.isLoggable(BaseTable.class)) {
                PropUtils.log(BaseTable.class, "Cancelling edit due to keyboard event"); //NOI18N
            }

            if (tce != null) {
                jt.getCellEditor().cancelCellEditing();
            }
        } else {
            //If we're in a dialog, try to close it
            trySendEscToDialog(jt);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:BaseTable.java

示例2: renameDomainInComponents

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Rename domain in components.
 *
 * @param oldDomainName the old domain name
 * @param newDomainName the new domain name
 */
public void renameDomainInComponents(String oldDomainName, String newDomainName) {
	
	DefaultTableModel dtmComponents = this.getTableModel4ComponentTypes();
	int column = getColumnHeaderIndexComponents(COL_Domain);
	
	// --- Get the component type definitions from table ----
	JTable jtComponents = this.getJTable4ComponentTypes();
	// --- Confirm, apply changes in table ------------------						
	TableCellEditor tceComponents = jtComponents.getCellEditor();
	if (tceComponents!=null) {
		tceComponents.stopCellEditing();
	}
	for(int row=0; row<dtmComponents.getRowCount(); row++){
		String currValue = (String) dtmComponents.getValueAt(row, column);
		if (currValue.equals(oldDomainName)) {
			dtmComponents.setValueAt(newDomainName, row, column);	
		}
	}
	this.setTableCellEditor4DomainsInComponents(null);
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:27,代码来源:ComponentTypeDialog.java

示例3: mouseClicked

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
    JTableHeader h = (JTableHeader) e.getSource();
    JTable table = h.getTable();
    int selectedRow = table.getSelectedRow();
    TableModel model = table.getModel();
    //remember selection to keep after sorting
    Object selectedAction=null;
    int objectColumn=-1;
    if(selectedRow>-1) {
        for(int i=0; i<table.getColumnCount(); i++) {
            //first find colum with appropriate object
            if(model.getValueAt(selectedRow, i) instanceof ActionHolder) {
                //remember this object
                selectedAction=model.getValueAt(selectedRow, i);
                objectColumn=i;
                //stop edition as we click somewhere ouside of editor
                TableCellEditor editor=table.getCellEditor();
                if(editor!=null) {
                    editor.stopCellEditing();
                }
                break;
            }
        }
    }
    TableColumnModel columnModel = h.getColumnModel();
    int viewColumn = columnModel.getColumnIndexAtX(e.getX());
    int column = columnModel.getColumn(viewColumn).getModelIndex();
    if (column != -1) {
        int status = getSortingStatus(column);
        if (!e.isControlDown()) {
            cancelSorting();
        }
        // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or 
        // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed. 
        status = status + (e.isShiftDown() ? -1 : 1);
        status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
        setSortingStatus(column, status);
        //reselect the same object
        if(selectedAction!=null)setSelectedRow(table, selectedAction, objectColumn);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:TableSorter.java

示例4: testEditors

import javax.swing.JTable; //导入方法依赖的package包/类
public void testEditors() {
    setUpModel();
    JTable t = ot.treeTable.getTable();
    ot.revalidate();

    javax.swing.JFrame f = new javax.swing.JFrame();
    f.setLayout(new BorderLayout());
    f.add(ot, BorderLayout.CENTER);
    f.setSize(600, 500);
    f.setVisible(true);
    //while (f.isVisible()) {
        try {
            Thread.sleep(333);
        } catch (InterruptedException ex) {
            Exceptions.printStackTrace(ex);
        }
    //}

    System.out.println("table rows = "+t.getRowCount());
    TableCellEditor tce = t.getCellEditor(0, 0);
    assertTrue(tce+"is not editable.", tce.isCellEditable(getMouseClickAt(t, 0, 0)));
    //assertTrue(t+"is not editable.", t.isCellEditable(0, 0));
    Component c = tce.getTableCellEditorComponent(t, null, true, 0, 0);
    //System.err.println("c = "+c);
    assertTrue("Editor component = "+c, c instanceof EditorComponent);
    assertEquals("Editor of 0:DN", ((EditorComponent) c).getText());

    tce = t.getCellEditor(0, 1);
    assertTrue(tce+"is not editable.", tce.isCellEditable(getMouseClickAt(t, 0, 1)));
    assertTrue(t+"is not editable.", t.isCellEditable(0, 1));
    c = tce.getTableCellEditorComponent(t, null, true, 0, 1);
    assertTrue("Editor component = "+c, c instanceof EditorComponent);
    assertEquals("Editor of 0:col1", ((EditorComponent) c).getText());

    tce = t.getCellEditor(0, 2);
    assertTrue(tce+"is not editable.", tce.isCellEditable(getMouseClickAt(t, 0, 2)));
    assertTrue(t+"is not editable.", t.isCellEditable(0, 2));
    c = tce.getTableCellEditorComponent(t, null, true, 0, 2);
    assertTrue("Editor component = "+c, c instanceof EditorComponent);
    assertEquals("Editor of 0:col2", ((EditorComponent) c).getText());

    tce = t.getCellEditor(1, 0);
    assertFalse(tce+"is editable.", tce.isCellEditable(getMouseClickAt(t, 1, 0)));
    assertFalse(t+"is editable.", t.isCellEditable(1, 0));
    c = tce.getTableCellEditorComponent(t, null, true, 1, 0);
    assertFalse("Editor component = "+c, c instanceof EditorComponent);

    tce = t.getCellEditor(1, 2);
    assertFalse(tce+"is editable.", tce.isCellEditable(getMouseClickAt(t, 1, 2)));
    assertFalse(t+"is editable.", t.isCellEditable(1, 2));
    c = tce.getTableCellEditorComponent(t, null, true, 1, 2);
    assertFalse("Editor component = "+c, c instanceof EditorComponent);

    tce = t.getCellEditor(3, 1);
    assertTrue(tce+"is not editable.", tce.isCellEditable(getMouseClickAt(t, 3, 1)));
    assertTrue(t+"is not editable.", t.isCellEditable(3, 1));
    c = tce.getTableCellEditorComponent(t, null, true, 3, 1);
    assertTrue("Editor component = "+c, c instanceof EditorComponent);
    assertEquals("Editor of 3:col1", ((EditorComponent) c).getText());

    tce = t.getCellEditor(6, 0);
    assertTrue(tce+"is not editable.", tce.isCellEditable(getMouseClickAt(t, 6, 0)));
    assertTrue(t+"is not editable.", t.isCellEditable(6, 0));
    c = tce.getTableCellEditorComponent(t, null, true, 6, 0);
    assertTrue("Editor component = "+c, c instanceof EditorComponent);
    assertEquals("Editor of 6:DN", ((EditorComponent) c).getText());

    tce = t.getCellEditor(9, 2);
    assertTrue(tce+"is not editable.", tce.isCellEditable(getMouseClickAt(t, 9, 2)));
    assertTrue(t+"is not editable.", t.isCellEditable(9, 2));
    c = tce.getTableCellEditorComponent(t, null, true, 9, 2);
    assertTrue("Editor component = "+c, c instanceof EditorComponent);
    assertEquals("Editor of 9:col2", ((EditorComponent) c).getText());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:75,代码来源:TableRendererTest.java

示例5: cancelEditing

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * stops the tmodel cell editing
 *
 * @param table the target tmodel
 */
public static void cancelEditing(JTable table) {
    if (table.getCellEditor() != null) {
        table.getCellEditor().cancelCellEditing();
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:11,代码来源:JtableUtils.java

示例6: stopEditing

import javax.swing.JTable; //导入方法依赖的package包/类
public static void stopEditing(JTable table) {
    if (null != table.getCellEditor()) {
        table.getCellEditor().stopCellEditing();
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:6,代码来源:JtableUtils.java


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