After five days of banging my head on this problem I have found somewhat of an answer. For some reason swing only wants to refresh the scrollbar if an event occurs. When someone clicked in my tree and event occurred and it was happy about running the setValue command to scroll the bar to the top. However, my ultimate goal was to change the text each time someone clicked in the tree, which would set the scroll bar back to the bottom. So I needed another type of event to occur that would not involve the user clicking. After all, what I am trying to avoid in the first place is making the user drag the scrollbar back to the top. So it occurred to me to do the following...
...and add a method like this.
If I ever want to put the scroll bar at the top I just call timer.start();. The setValue() method will run inside the event even though it won't other places. I hope that helps someone in the future. Does anybody with any better knowledge of the way this all work have an explanation as to why it behaves this way? Is it a bug in Swing?
Have you no shame? Have you no decency? Have you no tiny ad?
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth