Java DefaultCellEditor .setClickCountToStart (int count)
Syntax
DefaultCellEditor.setClickCountToStart(int count) has the following syntax.
public void setClickCountToStart(int count)
Example
In the following code shows how to use DefaultCellEditor.setClickCountToStart(int count) method.
//from ww w . j a v a 2s. c om
import java.awt.BorderLayout;
import javax.swing.DefaultCellEditor;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellEditor;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellEditor;
public class Main {
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);
JScrollPane scrollPane = new JScrollPane(tree);
frame.add(scrollPane, BorderLayout.CENTER);
frame.setSize(300, 150);
frame.setVisible(true);
}
}
Home »
Java Tutorial »
javax.swing »
Java Tutorial »
javax.swing »