Results 1 to 2 of 2
  1. #1
    PrinceSendai is offline Member
    Join Date
    Jul 2010
    Location
    Lima, Peru
    Posts
    47
    Rep Power
    0

    Default Keep a JTree from collapsing

    I don't know if this is a method from the DefaultMutableTreeNode or from the JTree... But whenever I double click a node, it collapses.


    I don't want the double click to collapse the nodes. I want the tree to be always expanded.


    More specifically, I want the ROOT node to be always expanded, even if the user double clicks on it (don't want it to collapse).


    How do I do this?


    I have tried "tree.expandRow(0);" and calling it at the very end of the valueChanged() event method. However, it seems not to work. The tree still collapses when I double click on it.


    Thanks

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,303
    Rep Power
    20

    Default Re: Keep a JTree from collapsing

    Read the API for JTree and note the various listeners that can be added via the addXxxListener(...) methods. One of the listeners is capable of providing the functionality you seek, and its API has a link to the Oracle tutorial that describes accurately, with a code sample, how to prevent a node from expanding.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Collapsing Box Problems
    By AsylumDreams in forum Advanced Java
    Replies: 2
    Last Post: 01-14-2010, 04:04 AM
  2. Move JTree item to another JTree.
    By Melki in forum AWT / Swing
    Replies: 8
    Last Post: 07-09-2009, 11:59 AM
  3. Collapsing/Expanding() All nodes in a TreeMenu using javascript
    By Hadley in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 01-30-2009, 11:18 PM
  4. nested collapsing list
    By roohja in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 01-05-2009, 07:15 AM
  5. Replies: 3
    Last Post: 12-15-2007, 11:19 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •