Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / April 2006

Tip: Looking for answers? Try searching our database.

How to select a leaf in a JTree using a JButton

Thread view: 
w3stkillah@gmail.com - 11 Apr 2006 11:21 GMT
Here's the deal. I need to select a leaf in a jtree using a click on a
button. I'm making some kind of MP3 player so when i press "next" i
need it to select the next leaf. When "shuffle" is pressed i need it to
select a random leaf. How do i do it?
Thomas Weidenfeller - 11 Apr 2006 12:18 GMT
> Here's the deal. I need to select a leaf in a jtree using a click on a
> button. I'm making some kind of MP3 player so when i press "next" i
> need it to select the next leaf. When "shuffle" is pressed i need it to
> select a random leaf. How do i do it?

setSelectionPath(), as you could easily have found out reading the API
documentation.

/Thomas
w3stkillah@gmail.com - 12 Apr 2006 13:26 GMT
I read the API. I had problems because  the argument of
setSelectionPath() is TreePath. But i think i got it:
tree.setSelectionPath( new TreePath( node.getPath() ) );
Thanks!
Thomas Weidenfeller - 12 Apr 2006 14:10 GMT
> I read the API. I had problems because  the argument of
> setSelectionPath() is TreePath.

So why didn't you ask about TreePath then?

Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.