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


Java TableCellEditor.getTableCellEditorComponent方法代碼示例

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


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

示例1: getTableCellEditorComponent

import javax.swing.table.TableCellEditor; //導入方法依賴的package包/類
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    Outline outline = (Outline) table;
    Node n = DelegatingCellRenderer.getNodeAt(outline, row);
    if (n instanceof TreeModelNode) {
        TreeModelNode tmn = (TreeModelNode) n;
        TableRendererModel trm = tmn.getModel();
        try {
            if (trm.canEditCell(tmn.getObject(), columnID)) {
                TableCellEditor editor = trm.getCellEditor(tmn.getObject(), columnID);
                if (editor != null) {
                    currentEditor = editor;
                    return editor.getTableCellEditorComponent(table, value, isSelected, row, column);
                }
            }
        } catch (UnknownTypeException ex) {
        }
    }
    // No specific editor
    currentEditor = defaultEditor;
    return defaultEditor.getTableCellEditorComponent(table, value, isSelected, row, column);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:DelegatingCellEditor.java

示例2: prepareEditor

import javax.swing.table.TableCellEditor; //導入方法依賴的package包/類
/** Overridden to set the colors apropriately - we always want the editor
 * to appear selected */
public Component prepareEditor(TableCellEditor editor, int row, int col) {
    Component result = editor.getTableCellEditorComponent(this, getValueAt(row, col), false, row, col);

    if (result != null) {
        result.setBackground(getSelectionBackground());
        result.setForeground(getSelectionForeground());
        result.setFont(getFont());
    }

    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:BaseTable.java

示例3: prepareEditor

import javax.swing.table.TableCellEditor; //導入方法依賴的package包/類
public Component prepareEditor(TableCellEditor editor, int index) {
	Object value = columnModel.getColumn(index).getHeaderValue();
	boolean isSelected = true;
	int row = HEADER_ROW;
	JTable table = getTable();
	Component comp = editor.getTableCellEditorComponent(table, value, isSelected, row, index);
	if (comp instanceof JComponent) {
		((JComponent) comp).setNextFocusableComponent(this);
	}
	return comp;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:12,代碼來源:EditableTableHeader.java

示例4: testEditors

import javax.swing.table.TableCellEditor; //導入方法依賴的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


注:本文中的javax.swing.table.TableCellEditor.getTableCellEditorComponent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。