本文整理汇总了Java中javax.swing.tree.TreeCellEditor类的典型用法代码示例。如果您正苦于以下问题:Java TreeCellEditor类的具体用法?Java TreeCellEditor怎么用?Java TreeCellEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TreeCellEditor类属于javax.swing.tree包,在下文中一共展示了TreeCellEditor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: synchronizeRootContext
import javax.swing.tree.TreeCellEditor; //导入依赖的package包/类
/** Synchronize the root context from the manager of this Explorer.
*/
final void synchronizeRootContext() {
// #151850 cancel editing before changing root node
Mutex.EVENT.readAccess(new Runnable() {
@Override
public void run() {
TreeCellEditor cellEditor = tree.getCellEditor();
if (cellEditor instanceof TreeViewCellEditor) {
((TreeViewCellEditor) cellEditor).abortTimer();
}
tree.cancelEditing();
final Node rc = manager.getRootContext();
LOG.log(Level.FINE, "synchronizeRootContext {0}", rc);
treeModel.setNode(rc, visHolder);
}
});
}
示例2: uninstallListeners
import javax.swing.tree.TreeCellEditor; //导入依赖的package包/类
/**
* Uninstall all registered listeners
*/
protected void uninstallListeners()
{
tree.removePropertyChangeListener(propertyChangeListener);
tree.removeFocusListener(focusListener);
tree.removeTreeSelectionListener(treeSelectionListener);
tree.removeMouseListener(mouseListener);
tree.removeKeyListener(keyListener);
tree.removePropertyChangeListener(selectionModelPropertyChangeListener);
tree.removeComponentListener(componentListener);
tree.removeTreeExpansionListener(treeExpansionListener);
TreeCellEditor tce = tree.getCellEditor();
if (tce != null)
tce.removeCellEditorListener(cellEditorListener);
if (treeModel != null)
treeModel.removeTreeModelListener(treeModelListener);
}
示例3: propertyChange
import javax.swing.tree.TreeCellEditor; //导入依赖的package包/类
public void propertyChange(final PropertyChangeEvent e) {
String changedProperty = e.getPropertyName();
if (JTree.CELL_RENDERER_PROPERTY.equals(changedProperty)) {
setCellRenderer((TreeCellRenderer)e.getNewValue());
} else if (JTree.CELL_EDITOR_PROPERTY.equals(changedProperty)) {
setCellEditor((TreeCellEditor)e.getNewValue());
} else if (JTree.TREE_MODEL_PROPERTY.equals(changedProperty)) {
setModel((TreeModel)e.getNewValue());
} else if (JTree.ROOT_VISIBLE_PROPERTY.equals(changedProperty)) {
setRootVisible(((Boolean)e.getNewValue()).booleanValue());
} else if (JTree.SHOWS_ROOT_HANDLES_PROPERTY.equals(changedProperty)) {
setShowsRootHandles(((Boolean)e.getNewValue()).booleanValue());
} else if (JTree.ROW_HEIGHT_PROPERTY.equals(changedProperty)) {
setRowHeight(((Integer)e.getNewValue()).intValue());
} else if (JTree.EDITABLE_PROPERTY.equals(changedProperty)) {
setEditable(((Boolean)e.getNewValue()).booleanValue());
} else if (JTree.LARGE_MODEL_PROPERTY.equals(changedProperty)) {
setLargeModel(((Boolean)e.getNewValue()).booleanValue());
} else if (JTree.SELECTION_MODEL_PROPERTY.equals(changedProperty)) {
setSelectionModel((TreeSelectionModel)e.getNewValue());
} else if (JTree.LEAD_SELECTION_PATH_PROPERTY.equals(changedProperty)) {
TreePath leadPath = (TreePath)e.getNewValue();
lastSelectedRow = leadPath != null ? tree.getRowForPath(leadPath) : -1;
}
}
示例4: createTreeCellEditor
import javax.swing.tree.TreeCellEditor; //导入依赖的package包/类
/**
* This is invoked if a TreeCellEditor is not supplied in the constructor.
* It returns a TextField editor.
*/
@Override
protected TreeCellEditor createTreeCellEditor() {
JTextField tf = new JTextField() {
@Override
public void addNotify() {
stopped = cancelled = false;
super.addNotify();
requestFocus();
}
};
//#137454 - text not visible in in-place editor
String laf = UIManager.getLookAndFeel().getID();
if( "GTK".equals( laf ) ) { //NOI18N
tf.setBorder( BorderFactory.createEmptyBorder() );
} else if( "Nimbus".equals( laf ) ) { //NOI18N
tf.setBorder( BorderFactory.createLineBorder( new JTree().getBackground() ) );
}
tf.registerKeyboardAction( //TODO update to use inputMap/actionMap
this, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, true), JComponent.WHEN_FOCUSED);
tf.addFocusListener(this);
Ed ed = new Ed(tf);
ed.setClickCountToStart(1);
ed.getComponent().getAccessibleContext().setAccessibleDescription(
NbBundle.getMessage(TreeViewCellEditor.class, "ACSD_TreeViewCellEditor")
); // NOI18N
ed.getComponent().getAccessibleContext().setAccessibleName(
NbBundle.getMessage(TreeViewCellEditor.class, "ACSN_TreeViewCellEditor")
); // NOI18N
return ed;
}
示例5: createDefaultCellEditor
import javax.swing.tree.TreeCellEditor; //导入依赖的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;
}
示例6: createTreeCellEditor
import javax.swing.tree.TreeCellEditor; //导入依赖的package包/类
@Override
protected TreeCellEditor createTreeCellEditor() {
JTextField tf = new JTextField() {
@Override
public String getName() {
return "Tree.cellEditor";
}
};
DefaultCellEditor editor = new DefaultCellEditor(tf);
// One click to edit.
editor.setClickCountToStart(1);
return editor;
}
示例7: createTreeCellEditor
import javax.swing.tree.TreeCellEditor; //导入依赖的package包/类
@Override
protected TreeCellEditor createTreeCellEditor() {
@SuppressWarnings("serial") // anonymous class
JTextField tf = new JTextField() {
@Override
public String getName() {
return "Tree.cellEditor";
}
};
DefaultCellEditor editor = new DefaultCellEditor(tf);
// One click to edit.
editor.setClickCountToStart(1);
return editor;
}
示例8: getCellEditor
import javax.swing.tree.TreeCellEditor; //导入依赖的package包/类
/**
* Maps {@code JTree.getCellEditor()} through queue
*/
public TreeCellEditor getCellEditor() {
return (runMapping(new MapAction<TreeCellEditor>("getCellEditor") {
@Override
public TreeCellEditor map() {
return ((JTree) getSource()).getCellEditor();
}
}));
}
示例9: setCellEditor
import javax.swing.tree.TreeCellEditor; //导入依赖的package包/类
/**
* Maps {@code JTree.setCellEditor(TreeCellEditor)} through queue
*/
public void setCellEditor(final TreeCellEditor treeCellEditor) {
runMapping(new MapVoidAction("setCellEditor") {
@Override
public void map() {
((JTree) getSource()).setCellEditor(treeCellEditor);
}
});
}
示例10: setCellEditor
import javax.swing.tree.TreeCellEditor; //导入依赖的package包/类
public void setCellEditor(TreeCellEditor editor)
{
if (cellEditor == editor)
return;
TreeCellEditor oldValue = cellEditor;
cellEditor = editor;
firePropertyChange(CELL_EDITOR_PROPERTY, oldValue, editor);
}
示例11: updateCellEditor
import javax.swing.tree.TreeCellEditor; //导入依赖的package包/类
/**
* Updates the cellEditor based on editability of the JTree that we're
* contained in. If the tree is editable but doesn't have a cellEditor, a
* basic one will be used.
*/
protected void updateCellEditor()
{
completeEditing();
TreeCellEditor newEd = null;
if (tree != null && tree.isEditable())
{
newEd = tree.getCellEditor();
if (newEd == null)
{
newEd = createDefaultCellEditor();
if (newEd != null)
{
tree.setCellEditor(newEd);
createdCellEditor = true;
}
}
}
// Update listeners.
if (newEd != cellEditor)
{
if (cellEditor != null && cellEditorListener != null)
cellEditor.removeCellEditorListener(cellEditorListener);
cellEditor = newEd;
if (cellEditorListener == null)
cellEditorListener = createCellEditorListener();
if (cellEditor != null && cellEditorListener != null)
cellEditor.addCellEditorListener(cellEditorListener);
createdCellEditor = false;
}
}
示例12: getTreeCellEditorComponent
import javax.swing.tree.TreeCellEditor; //导入依赖的package包/类
@Override
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row) {
final ErrorTreeElement element = getElement(value);
if (element instanceof EditableMessageElement) {
EditableMessageElement editableMessageElement = (EditableMessageElement)element;
final CustomizeColoredTreeCellRenderer leftSelfRenderer = editableMessageElement.getLeftSelfRenderer();
final TreeCellEditor rightSelfEditor = editableMessageElement.getRightSelfEditor();
myColoredTreeCellRenderer.setCurrentCallback(leftSelfRenderer);
myRightCellRenderer.setCurrentCallback(rightSelfEditor);
return myWrapperEditor.getTreeCellEditorComponent(tree, value, selected, expanded, leaf, row);
}
return myTree.getCellRenderer().getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, true);
}
示例13: getCellEditorAndText
import javax.swing.tree.TreeCellEditor; //导入依赖的package包/类
@NotNull
private Pair<JEditorPane, String> getCellEditorAndText() {
// There is no specific UI component for a hyperlink in the "Messages" window. Instead we have a JEditorPane with HTML. This method
// finds the anchor tags, and matches the text of each of them against the given text. If a matching hyperlink is found, we fire a
// HyperlinkEvent, simulating a click on the actual hyperlink.
assertThat(myTarget).isInstanceOf(EditableNotificationMessageElement.class);
final JEditorPane editorComponent = execute(new GuiQuery<JEditorPane>() {
@Override
protected JEditorPane executeInEDT() throws Throwable {
EditableNotificationMessageElement message = (EditableNotificationMessageElement)myTarget;
TreeCellEditor cellEditor = message.getRightSelfEditor();
return field("editorComponent").ofType(JEditorPane.class).in(cellEditor).get();
}
});
assertNotNull(editorComponent);
String text = execute(new GuiQuery<String>() {
@Override
protected String executeInEDT() throws Throwable {
return editorComponent.getText();
}
});
assertNotNull(text);
return Pair.create(editorComponent, text);
}
示例14: createDefaultCellEditor
import javax.swing.tree.TreeCellEditor; //导入依赖的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.TreeCellEditor; //导入依赖的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;
}