I'm building a UI that looks somewhat like a gantt chart.
How I achieved this look was to have a JScrollPane in my main window frame. I set the viewport view to be a JList and the row header view to be a JTree. I have successfully managed to coordinate the expanding/collapsing of JTree nodes with the showing/hiding of JList items.
I have two problems. Assume both the JTree and JList require more display space than the scroll pane provides and therefore there is a scroll bar.
(1) When I scroll using the scroll bar, my JList repaints itself correctly but my JTree does not. For example, if I scroll down the list, each item moves up but the last item displayed mimics one before it. Obviously, the default scroll pane support is not enough.
- Can my JTree be a listener to something? What might that be?
(2) When I expand/collapse a tree node, sometimes it repositions the JTree in the row header panel. This is a problem because now my rows are out of sync.
- Is there a way I can disable the JTree from doing this? - If not, is there a way I can figure out how much it scrolled and then scroll it back? I'm afraid if I were to notify the scroll pane and ask it to scroll that much, it would only scroll the JTree again.
Any and all help is greatly appreciated!
Joined: Jan 08, 2002
Answer to (2):
subject: JTree + JList in JScrollPane - Out of Sync