my dog learned polymorphism
The moose likes Swing / AWT / SWT and the fly likes JTree flicker Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree flicker" Watch "JTree flicker" New topic

JTree flicker

Milesh Dcunha

Joined: Jun 19, 2006
Posts: 13
Hi All,

I have a JScrollPane on Which I am adding a JTree. I add data to the JTree dynamically based on the node selected. The data comes from the database. I use the pipeline function of Oracle to get me the data. I show the leaf nodes when they are added to the JTree.

When I click on a node the tree is populated with the data, but there is obvious flicker. When I put a System.out.println() to print something in the populate function the JTree dosen't flicker.

Instead of running the populate function in the main thread, I tried calling function using the SwingUtilities.invokeLater(), but it won't show the data until the JTree has the complete data.

So I again called the function from the main thread. But the flicker is still there.

Maybe I have missed something...but I am not finding a solution.

The world is becoming an orgy of self-sacrifice when it is precisely the self that should not be sacrificed.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

I'm not sure what you mean by "flicker". But you have two choices: you can collect the data and not display the JTree until it is completely loaded, or you can display it in various partial stages as you are loading.

You know how to do the first choice, because you described it in your post. So what's different between "flicker" and "displaying of partial results"? Is that not what you are seeing?
Milesh Dcunha

Joined: Jun 19, 2006
Posts: 13
Yes I can see the partial results.
But when the results are added the JTree flickers in the sense that I can see the repaint on the tree happening. Just like what happens when you don't have smooth animation in an applet...hope I am clear on what I mean by flickering.
I agree. Here's the link:
subject: JTree flicker
It's not a secret anymore!