This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Find function in Jtree..urgent!!

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I have a JTree component in an applet which has a JTextField below it. Now I want to type a node name in the textfield & when I press "Enter" key it should select. I'm able 2 do this but I also want it in such a way that if there are multiple nodes with the same name ,then on first "Enter" it should select the first one it got, again when I press "Enter" it should select the next node with the same name & so on..any ideas pls??
Also, the Jtree is contained in a scrollpane, if the tree is huge & a node is selected which is below the view of the scrollpane, then I have to manually move the scrollbar down to view the selected node, Is it possible to automatically scroll the scrollbar down when such a node is selected?
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinod,
I appreciate the effort at re-registering, but "Luke Skywalker" is also not in keeping with the JavaRanch Naming Policy. Please choose a name that meets the requirements and re-register. Please also note that the sheriffs can disable accounts that are not in accordance with this policy.
Bodie
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Sir,
I have re registered for the third time , I admit making a mistake the first time, but the second one would have been ok, Im sure, b'cos I just didnt want to disclose my personal info, but now I have & I do hope its private, & I really need a solution to my Java problem. Everytime I log in, I see something about my username. I kindly request you to accept this username as I'm running out of usernames.
Thanx,
Vinod
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the hassle, Vinod. The Ranch is trying to maintain a level of professionalism that the sherriffs feel can't be had with chatroom type usernames and aliases. The naming policy requires that we use first and last name and it can't be obviously ficticious (like Luke Skywalker, who I really happen to like! ). Anyway, I have never had anyone spam me or otherwise misuse my contact information, so I feel good about the privacy of it.
Finally....
I don't know the answer to the first part of your question, about finding successive occurrances of a given node. But the other part about scrolling to the selected node: If you nest your JTree inside of a JScrollPane (you mentioned that it is currently inside a ScrollPane and I don't know if this supports the method I'm recommending) you can make a call to scrollRowToVisible(). This method takes an int representing the row you want to make visible. You can see the API on line here and you may be able to find a better way than what I am suggesting.
Again, thanks for sticking with it and re-registering. The Ranch is a quality site because of the serious professionals like yourself that are actively participating in these forums!
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!