本文整理匯總了Java中javax.swing.tree.DefaultTreeCellEditor類的典型用法代碼示例。如果您正苦於以下問題:Java DefaultTreeCellEditor類的具體用法?Java DefaultTreeCellEditor怎麽用?Java DefaultTreeCellEditor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DefaultTreeCellEditor類屬於javax.swing.tree包,在下文中一共展示了DefaultTreeCellEditor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testStartEditing
import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
public void testStartEditing() {
assertFalse(ui.isEditing(tree));
ui.startEditing(new TreePath(root), null);
assertFalse(ui.isEditing(tree));
tree.setEditable(true);
assertFalse(ui.isEditing(tree));
ui.startEditing(new TreePath(root), null);
assertTrue(ui.isEditing(tree));
ui.cancelEditing(tree);
assertFalse(ui.isEditing(tree));
tree.setCellEditor(new DefaultTreeCellEditor(tree, (DefaultTreeCellRenderer) tree
.getCellRenderer()) {
@Override
public boolean shouldSelectCell(final EventObject event) {
return false;
}
});
ui.startEditing(new TreePath(root), null);
assertTrue(ui.isEditing(tree));
}
示例2: createDefaultCellEditor
import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
protected TreeCellEditor createDefaultCellEditor() {
TreeCellRenderer renderer = tree.getCellRenderer();
DefaultTreeCellEditor editor;
if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
renderer);
}
else {
editor = new SynthTreeCellEditor(tree, null);
}
return editor;
}
示例3: testEditorListenerRemovedOnEditorStopped
import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
* focus issues with popup in editors: tweak with
* custom cellEditorListener.
*
*/
@Test
public void testEditorListenerRemovedOnEditorStopped() {
JXTree tree = createEditingTree();
DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
// core doesn't remove the listener ... dooh
cellEditor.stopCellEditing();
// but we do ...
assertEquals(1, cellEditor.getCellEditorListeners().length);
}
示例4: testEditorListenerRemovedOnEditorCancel
import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
* focus issues with popup in editors: tweak with
* custom cellEditorListener.
*
*/
@Test
public void testEditorListenerRemovedOnEditorCancel() {
JXTree tree = createEditingTree();
DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
// core doesn't remove the listener ... dooh
cellEditor.cancelCellEditing();
// but we do ...
assertEquals(1, cellEditor.getCellEditorListeners().length);
}
示例5: testEditorListenerRemovedOnTreeCancel
import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
* focus issues with popup in editors: tweak with
* custom cellEditorListener.
*
*/
@Test
public void testEditorListenerRemovedOnTreeCancel() {
JXTree tree = createEditingTree();
DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
// core doesn't remove the listener ... dooh
tree.cancelEditing();
// but we do ...
assertEquals(1, cellEditor.getCellEditorListeners().length);
}
示例6: testEditorListenerRemovedOnTreeStop
import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
* focus issues with popup in editors: tweak with
* custom cellEditorListener.
*
*/
@Test
public void testEditorListenerRemovedOnTreeStop() {
JXTree tree = createEditingTree();
DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
// core doesn't remove the listener ... dooh
tree.stopEditing();
// but we do ...
assertEquals(1, cellEditor.getCellEditorListeners().length);
}
示例7: testEditorListenerOnXTree
import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
* focus issues with popup in editors: tweak with
* custom cellEditorListener.
*
*/
@Test
public void testEditorListenerOnXTree() {
JTree core = new JTree();
int coreCount = getListenerCountAfterStartEditing(core);
JXTree tree = createEditingTree();
DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
assertEquals("need one more listener than core",
coreCount + 1, cellEditor.getCellEditorListeners().length);
}
示例8: testEditorListenerOnCoreTree
import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
* characterization: listeners in core tree.
*
*/
@Test
public void testEditorListenerOnCoreTree() {
JTree tree = new JTree();
int listenerCount = getListenerCountAfterStartEditing(tree);
assertEquals(1, listenerCount);
tree.stopEditing();
// doesn't remove the listener ... dooh
assertEquals(1, ((DefaultTreeCellEditor) tree.getCellEditor()).getCellEditorListeners().length);
}
示例9: getListenerCountAfterStartEditing
import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
* Starts editing on row 2 and returns the cell editor listener count after.
*
* @param tree
* @return
*/
private int getListenerCountAfterStartEditing(JTree tree) {
tree.setEditable(true);
// sanity
assertTrue(tree.getRowCount() > 2);
TreePath path = tree.getPathForRow(2);
tree.startEditingAtPath(path);
DefaultTreeCellEditor cellEditor = (DefaultTreeCellEditor) tree.getCellEditor();
int listenerCount = cellEditor.getCellEditorListeners().length;
return listenerCount;
}
示例10: interactiveToggleEditProperties
import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
* visually check if invokesStopCellEditing jumps in on focusLost.
*
*/
public void interactiveToggleEditProperties() {
final JXTree table = new JXTree();
table.setEditable(true);
DefaultTreeCellEditor editor = new DefaultTreeCellEditor(null, null) {
@Override
public boolean stopCellEditing() {
String value = String.valueOf(getCellEditorValue());
if (value.startsWith("s")) {
return false;
}
return super.stopCellEditing();
}
};
table.setCellEditor(editor);
JXFrame frame = wrapWithScrollingInFrame(table, new JButton("something to focus"),
"JXTree: toggle invokesStopEditing ");
Action toggleTerminate = new AbstractAction("toggleInvokesStop") {
public void actionPerformed(ActionEvent e) {
table.setInvokesStopCellEditing(!table.getInvokesStopCellEditing());
}
};
addAction(frame, toggleTerminate);
frame.setVisible(true);
}
示例11: interactiveTreeEditingRToLDatePicker
import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
* visualize datepicker editing of the hierarchical column, both
* in a tree and a xTree switching CO.
*
* standard editor
*/
public void interactiveTreeEditingRToLDatePicker() {
TreeModel model = createTreeModelWithDates();
JTree tree = new JTree(model);
tree.setEditable(true);
tree.setCellEditor(new DefaultTreeCellEditor(tree, null, new DatePickerCellEditor()));
JXTree xTree = new JXTree(model);
xTree.setEditable(true);
xTree.setCellEditor(new DefaultTreeCellEditor(tree, null, new DatePickerCellEditor()));
final JXFrame frame = wrapWithScrollingInFrame(tree, xTree, "standard Editing (DatePicker): compare tree and xtree");
addComponentOrientationToggle(frame);
show(frame);
}
示例12: ProjectTree
import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
* Constructor
*/
public ProjectTree() {
ProjectTreeRenderer renderer = new ProjectTreeRenderer();
setCellRenderer(renderer);
DefaultTreeCellEditor editor = new DefaultTreeCellEditor(this,
renderer, new ProjectTreeEditor(this));
setCellEditor(editor);
setEditable(true);
setInvokesStopCellEditing(true);
setRootVisible(true);
setShowsRootHandles(false);
setToggleClickCount(-1);
// Activate drag&drop
ProjectTreeDnDHandler dndHandler = new ProjectTreeDnDHandler();
setTransferHandler(dndHandler);
setDropMode(DropMode.INSERT);
setDragEnabled(true);
// Attach a handler for handling popup menus and double clicks
ProjectTreeMouseHandler popupHandler = new ProjectTreeMouseHandler(this);
addMouseListener(popupHandler);
}
示例13: createDefaultCellEditor
import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
* @inheritDoc
*/
@Override
protected TreeCellEditor createDefaultCellEditor() {
TreeCellRenderer renderer = tree.getCellRenderer();
DefaultTreeCellEditor editor;
if (renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer) renderer);
} else {
editor = new SynthTreeCellEditor(tree, null);
}
return editor;
}
示例14: createDefaultCellEditor
import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
/**
* @inheritDoc
*/
@Override
protected TreeCellEditor createDefaultCellEditor() {
TreeCellRenderer renderer = tree.getCellRenderer();
DefaultTreeCellEditor editor;
if(renderer != null && (renderer instanceof DefaultTreeCellRenderer)) {
editor = new SynthTreeCellEditor(tree, (DefaultTreeCellRenderer)
renderer);
}
else {
editor = new SynthTreeCellEditor(tree, null);
}
return editor;
}
示例15: createDefaultCellEditor
import javax.swing.tree.DefaultTreeCellEditor; //導入依賴的package包/類
protected TreeCellEditor createDefaultCellEditor() {
DefaultTreeCellRenderer renderer = currentCellRenderer instanceof DefaultTreeCellRenderer
? (DefaultTreeCellRenderer)currentCellRenderer
: null;
return new DefaultTreeCellEditor(tree, renderer);
}