?
Solved

Make a tree node visible

Posted on 2001-09-04
3
Medium Priority
?
593 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
[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
  • 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 150 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

Independent Software Vendors: 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

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…
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 the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses
Course of the Month10 days, 6 hours left to enroll

765 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