How can i avoid the call to  tree selection or how can a avoid method to get called written tree selection listener when a node in Jtree is collapsed.

Posted on 2011-04-19
Last Modified: 2012-05-11


I am using Jtree With root node name Alphanumeric.

Root has three nodes as node1, node2, node3.
Node1 contain three leaf node as leafnodeA, leafnodeB, leafnodeC.
Node2 contain three leaf node as leafnodeD, leafnodeE, leafnodeF.
Node3 contain three leaf node as leafnodeG, leafnodeH, leafnodeI.

When i selects multiple leafnode say leafnodeA, leafnodeE and leafnodeH. i am able to get all selected value.

when i collapse a node say node3, the tree selection listener gets called.
How can i avoid the call to  tree selection or how can avoid method to call written tree selection listener when a node is collapsed.

Any kind of help with code snippets is appreciated.
Question by:Computer07
    LVL 92

    Accepted Solution

    Sounds like its firing because the selection gets *unselected*
    So in your listener you want to check if the selection was added and only take action if it is ie. ignore selections being removed.

    Author Closing Comment

    Thanks, now its working properly.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    scoreUp challenge 14 40
    word0 challenge 3 28
    HashMap Vs TreeMap 12 31
    java  and programming certification ? 4 27
    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now