Java DefaultCellEditor(JCheckBox checkBox) Constructor
Syntax
DefaultCellEditor(JCheckBox checkBox) constructor from DefaultCellEditor has the following syntax.
public DefaultCellEditor(JCheckBox checkBox)
Example
In the following code shows how to use DefaultCellEditor.DefaultCellEditor(JCheckBox checkBox) constructor.
//from w w w.j a v a 2 s.com
import java.awt.BorderLayout;
import javax.swing.DefaultCellEditor;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTree;
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);
Object array[] = {Boolean.TRUE, Boolean.FALSE, "Hello"};
JTree tree = new JTree(array);
tree.setEditable(true);
tree.setRootVisible(true);
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);
}
}
Home »
Java Tutorial »
javax.swing »
Java Tutorial »
javax.swing »