Java Code Examples for javax.swing.tree.TreeCellEditor

The following examples show how to use javax.swing.tree.TreeCellEditor. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: netbeans   Source File: TreeView.java    License: Apache License 2.0 6 votes vote down vote up
/** 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);
        }
    });
}
 
Example 2
Source Project: material-ui-swing   Source File: MaterialTreeUI.java    License: MIT License 6 votes vote down vote up
@Override
public void installUI (JComponent c) {
	super.installUI (c);

	DefaultTreeCellRenderer renderer = new MaterialTreeCellRenderer ();
	TreeCellEditor editor = new MaterialTreeCellEditor (tree, renderer);

	tree.setCellRenderer (renderer);
	tree.setCellEditor (editor);

	tree.setFont (UIManager.getFont ("Tree.font"));
	tree.setForeground (UIManager.getColor ("Tree.foreground"));
	tree.setBackground (UIManager.getColor ("Tree.background"));
	tree.setRowHeight (0);
	tree.setInvokesStopCellEditing (true);

	MaterialTreeUI ui = (MaterialTreeUI) tree.getUI ();
	ui.setLeftChildIndent (10);
	ui.setRightChildIndent (10);

	tree.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
 
Example 3
Source Project: darklaf   Source File: DarkUIUtil.java    License: MIT License 5 votes vote down vote up
public static boolean isInCell(final Component c) {
    if (getParentOfType(DarkTableHeaderRendererPane.class, c, CELL_SEARCH_DEPTH) != null) return false;
    boolean inCellRenderer = getParentOfType(c, CELL_SEARCH_DEPTH, CellRendererPane.class, CellEditor.class,
                                             TableCellRenderer.class, TableCellEditor.class,
                                             TreeCellRenderer.class, TreeCellEditor.class,
                                             ListCellRenderer.class, CellRenderer.class) != null;
    return inCellRenderer && getParentOfType(JComboBox.class, c) == null;
}
 
Example 4
Source Project: jdk1.8-source-analysis   Source File: SynthTreeUI.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@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;
}
 
Example 5
Source Project: jdk1.8-source-analysis   Source File: SynthTreeUI.java    License: Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 6
Source Project: dragonwell8_jdk   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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;
}
 
Example 7
Source Project: dragonwell8_jdk   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 8
Source Project: TencentKona-8   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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;
}
 
Example 9
Source Project: TencentKona-8   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 10
Source Project: jdk8u60   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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;
}
 
Example 11
Source Project: jdk8u60   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 12
Source Project: JDKSourceCode1.8   Source File: SynthTreeUI.java    License: MIT License 5 votes vote down vote up
/**
 * {@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;
}
 
Example 13
Source Project: JDKSourceCode1.8   Source File: SynthTreeUI.java    License: MIT License 5 votes vote down vote up
@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;
}
 
Example 14
Source Project: openjdk-jdk8u   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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;
}
 
Example 15
Source Project: openjdk-jdk8u   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 16
Source Project: netbeans   Source File: TreeViewCellEditor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 17
/**
 * {@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;
}
 
Example 18
@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;
}
 
Example 19
Source Project: Bytecoder   Source File: SynthTreeUI.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@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;
}
 
Example 20
Source Project: Bytecoder   Source File: SynthTreeUI.java    License: Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 21
Source Project: openjdk-jdk9   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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;
}
 
Example 22
Source Project: openjdk-jdk9   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 23
Source Project: openjdk-jdk9   Source File: JTreeOperator.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JTree.getCellEditor()} through queue
 */
public TreeCellEditor getCellEditor() {
    return (runMapping(new MapAction<TreeCellEditor>("getCellEditor") {
        @Override
        public TreeCellEditor map() {
            return ((JTree) getSource()).getCellEditor();
        }
    }));
}
 
Example 24
Source Project: openjdk-jdk9   Source File: JTreeOperator.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
        }
    });
}
 
Example 25
Source Project: jdk8u-jdk   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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;
}
 
Example 26
Source Project: jdk8u-jdk   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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;
}
 
Example 27
Source Project: Java8CN   Source File: SynthTreeUI.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@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;
}
 
Example 28
Source Project: Java8CN   Source File: SynthTreeUI.java    License: Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 29
Source Project: hottub   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@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;
}
 
Example 30
Source Project: hottub   Source File: SynthTreeUI.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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;
}