Solved

Make a tree node visible

Posted on 2001-09-04
3
590 Views
Last Modified: 2006-11-17
I have a JTree in a scroll pane.
I want that after every change selection (not only the mouse, but also using the keyboard), the selected node will be seen.
I've added a listener to catch the change selection events and in the event i call to scrollPathToVisible method.
It simply doesn't work.
Can you tell me why?
0
Comment
Question by:rzvika
  • 2
3 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 6453290
> It simply doesn't work.

post a small compilable example that reproduces the problem
0
 
LVL 16

Expert Comment

by:Valeri
ID: 6453452
Hi Rzvika,

I have heard for it :
It's Swing bug, which is reported on Sun web site. There is workaround for it. Just call the function twice :

scrollTreePathToVisible(tree, path);
scrollTreePathToVisible(tree, path);

Best regards,
Valeri
0
 
LVL 16

Accepted Solution

by:
Valeri earned 50 total points
ID: 6453543
Sorry, call the function twice :

tree.scrollPathToVisible(treePath);
tree.scrollPathToVisible(treePath);

You can use makeVisible(path) as well... What do you exactly want ?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.

735 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