本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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());
}