JCheckBox in a JTree

Discussion in 'Java' started by Steve, Feb 19, 2004.

  1. Steve

    Steve Guest

    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?
    Steve, Feb 19, 2004
    #1
    1. Advertising

  2. Steve

    ak Guest

    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.
    ak, Feb 19, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eefke Gemmeke

    jCheckBox in a Jtable

    Eefke Gemmeke, Dec 15, 2003, in forum: Java
    Replies:
    2
    Views:
    17,440
    Steve W. Jackson
    Dec 17, 2003
  2. Russell
    Replies:
    1
    Views:
    6,191
    Russell
    Oct 20, 2004
  3. Mark Sizzler
    Replies:
    1
    Views:
    3,982
  4. yew y via JavaKB.com

    ploblem in jcheckbox

    yew y via JavaKB.com, Mar 30, 2005, in forum: Java
    Replies:
    0
    Views:
    367
    yew y via JavaKB.com
    Mar 30, 2005
  5. jumpz
    Replies:
    3
    Views:
    615
    Jean-Baptiste Nizet
    Nov 12, 2007
Loading...

Share This Page