Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DISCONTIGUOUS_TREE_SELECTION

Posted on 2004-08-13
13
Medium Priority
?
421 Views
Last Modified: 2008-01-09
DISCONTIGUOUS_TREE_SELECTION
    This is the default mode for the default tree selection model. With this mode, any combination of nodes can be selected.

I want to retrieve those nodes that are selected with the CTRL key (Metal look and feel),be it grouped or isolated.i read through the API but could'nt find the right method.Anybody knows how ?
expertmb,this time around excellent grade will be awarded.

0
Comment
Question by:rjopata
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
13 Comments
 
LVL 6

Assisted Solution

by:manuel_m
manuel_m earned 75 total points
ID: 11793362
Maybe this site would help you:

http://www.phptr.com/articles/article.asp?p=26327&seqNum=13

here: Table 10–4 Methods Used with Tree Selection Events

regards,
Manuel
0
 

Author Comment

by:rjopata
ID: 11793541
Wow thanks Manuel.I will check ur site and get back to u.
Thanks .
0
 
LVL 92

Accepted Solution

by:
objects earned 75 total points
ID: 11797907
TreePath[] paths = tree.getSelectionPaths();
0
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 

Author Comment

by:rjopata
ID: 11798878
I had tried this method earlier.the problem i had was if one holds down the CTRL key before selecting the nodes,a loop over path.length returns correctly the selected nodes,however if a node is selected and the CTRL key is held for subsequent selections ,the method returns duplicate selected nodes.have u encountered this ? give it a try !!!
0
 
LVL 92

Expert Comment

by:objects
ID: 11798890
no i haven't encoutered that.
can you post a small compilable example that reproduces the problem.
0
 

Author Comment

by:rjopata
ID: 11798997
object u seem to be right.i just made a simple app and it worked fine either way.i'm in transit now and on windows.earlier i had this problem on linux and need to check with my code to see what i made wrong,but i'm convinced now something was wrong.
Thanks a lot .i guess i will have to split this one between u and Manuel.His url is very helpful.
Thanks once again and enjoy ur day.
Cheers
0
 
LVL 92

Expert Comment

by:objects
ID: 11799113
0
 

Author Comment

by:rjopata
ID: 11808708
Anybody wants to show me the way ?
i am extracting the selected paths with the following      
public void valueChanged( TreeSelectionEvent event )
      {
            if( event.getSource() == tree )
            {
                                    TreePath[] paths = tree.getSelectionPaths();
                  if(paths==null)
                      return;
                  for(int i=0;i<paths.length;i++){
                  System.out.println( "Selected paths=" + paths[i]);
                  }
                  System.out.println( "=====================" );
            }
      }
the result is the following
Selected paths=[JTree, colors]
Selected paths=[JTree, colors, blue]
Selected paths=[JTree, colors, violet]
=====================
i want to retrieve the strings colors,blue,violet in each selected path.i initially thought of using the toString() method on paths[i] and then store it in another String array and then StringTokenizer it.this appears to be pretty inefficient to me.If anybody knows how best i can go around this problem kindly enlighten me.
Thanks in advance.
NB ofcourse if u request for points it will be given.
0
 
LVL 92

Expert Comment

by:objects
ID: 11808766
to get the nodes use:

Object[] path = paths[i].getPath();
0
 

Author Comment

by:rjopata
ID: 11808848
Yes  objects  !!! thats it. ur more than my teacher now.i guess i can proceed from here.Thanks a lot.
Do u need points for this one ( i guess so or ?)
0
 
LVL 92

Expert Comment

by:objects
ID: 11816081
Glad I could help, no points needed :)
0
 

Author Comment

by:rjopata
ID: 11817818
Thats the expert for u.Thanks once again.
0
 
LVL 92

Expert Comment

by:objects
ID: 11817970
:)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

670 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