Example usage for javax.swing DefaultCellEditor cancelCellEditing

List of usage examples for javax.swing DefaultCellEditor cancelCellEditing

Introduction

In this page you can find the example usage for javax.swing DefaultCellEditor cancelCellEditing.

Prototype

public void cancelCellEditing() 

Source Link

Document

Forwards the message from the CellEditor to the delegate.

Usage

From source file:Main.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("Editable Tree");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JTree tree = new JTree();
    tree.setEditable(true);//w w w.jav  a  2s . com

    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();

    DefaultCellEditor comboEditor = new DefaultCellEditor(new JTextField());

    comboEditor.cancelCellEditing();

    TreeCellEditor editor = new DefaultTreeCellEditor(tree, renderer, comboEditor);
    tree.setCellEditor(editor);

    JScrollPane scrollPane = new JScrollPane(tree);
    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 150);
    frame.setVisible(true);
}