Solved

Make a tree node visible

Posted on 2001-09-04
3
591 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 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

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

734 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