Example usage for javax.swing JTree setEditable

List of usage examples for javax.swing JTree setEditable

Introduction

In this page you can find the example usage for javax.swing JTree setEditable.

Prototype

@BeanProperty(description = "Whether the tree is editable.")
public void setEditable(boolean flag) 

Source Link

Document

Determines whether the tree is editable.

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);

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

    TreeCellEditor comboEditor = new DefaultCellEditor(new JTextField());
    TreeCellEditor editor = new DefaultTreeCellEditor(tree, renderer, comboEditor);
    tree.setCellEditor(editor);/*ww  w  .j  a v  a  2 s. c  o m*/

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

From source file:Main.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("Editable Tree");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Object array[] = { Boolean.TRUE, Boolean.FALSE, "Hello" };
    JTree tree = new JTree(array);
    tree.setEditable(true);
    tree.setRootVisible(true);//from  www. j av  a2 s  . c o m
    JCheckBox checkBox = new JCheckBox();
    TreeCellEditor editor = new DefaultCellEditor(checkBox);
    tree.setCellEditor(editor);

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

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);

    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();
    String elements[] = { "A", "B", "C", "D" };
    JComboBox comboBox = new JComboBox(elements);
    comboBox.setEditable(true);/*from w  ww .  j a  va  2s .  c o m*/
    TreeCellEditor comboEditor = new DefaultCellEditor(comboBox);
    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);
}

From source file:TreeEdit.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Object array[] = { Boolean.TRUE, Boolean.FALSE, "Hello" }; // Hello will map to false
    JTree tree = new JTree(array);
    tree.setEditable(true);
    tree.setRootVisible(true);// w ww . j a  v a  2  s  . c o  m

    JCheckBox checkBox = new JCheckBox();

    TreeCellEditor editor = new DefaultCellEditor(checkBox);
    tree.setCellEditor(editor);

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

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);

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

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

    System.out.println(comboEditor.getClickCountToStart());

    TreeCellEditor editor = new DefaultTreeCellEditor(tree, renderer, comboEditor);
    tree.setCellEditor(editor);/* w  ww  .ja  va  2 s .c  o m*/

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

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);

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

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

    comboEditor.cancelCellEditing();//from   ww  w . j ava  2s.  c  o  m

    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);
}

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);

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

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

    comboEditor.setClickCountToStart(3);

    TreeCellEditor editor = new DefaultTreeCellEditor(tree, renderer, comboEditor);
    tree.setCellEditor(editor);/*from  w w w.  j  av  a  2 s. c o m*/

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

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);

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

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

    System.out.println(comboEditor.getComponent());

    TreeCellEditor editor = new DefaultTreeCellEditor(tree, renderer, comboEditor);
    tree.setCellEditor(editor);/*from  ww w.ja v  a 2 s.co m*/

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

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);

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

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

    comboEditor.stopCellEditing();/*from w  w  w .  j a  v  a 2 s. co m*/

    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);
}

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);

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

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

    comboEditor.getCellEditorValue();/*from w w  w. j  av a2 s. c  o  m*/

    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);
}