JCheckBox in a JTree

S

Steve

I need to do some GUI implementation work in which a JTree is
implemented but each node in the tree needs to have a check box to
select/de-select that node as a User Interface requirement. I tried
simply creating a JCheckbox and adding it as a TreeNode but that simple
solution does not work:

DefaultMutableTreeNode category = null;
DefaultMutableTreeNode top =
new DefaultMutableTreeNode("Tree Test");
final JCheckBox check = new JCheckBox("Check Box test");
category = new DefaultMutableTreeNode(check);
top.add(category);

Can you suggest some code that would add a checkbox (and listener of
course) to each tree node that I add to the tree?
 
A

ak

you should ask such questions in comp.lang.java.gui.
Can you suggest some code that would add a checkbox (and listener of
course) to each tree node that I add to the tree?

you need your own TreeCellRenderer/TreeCellEditor

____________

http://reader.imagero.com the best java image reader.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top