Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JCheckBox in a JTree

Reply
Thread Tools

JCheckBox in a JTree

 
 
Steve
Guest
Posts: n/a
 
      02-19-2004
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?

 
Reply With Quote
 
 
 
 
ak
Guest
Posts: n/a
 
      02-19-2004
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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JTree Selection lost when JTree looses focus jumpz Java 3 11-12-2007 03:55 PM
ploblem in jcheckbox yew y via JavaKB.com Java 0 03-30-2005 02:48 AM
How do I put a JCheckBox into a cell of a JTable? Mark Sizzler Java 1 03-03-2005 08:17 AM
JCheckBox Array - isSelected()... help please Russell Java 1 10-20-2004 09:33 AM
jCheckBox in a Jtable Eefke Gemmeke Java 2 12-17-2003 07:30 PM



Advertisments