This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
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.
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?
Joined: Jun 19, 2006
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.