posted 19 years ago
Okay, so I have been pondering this some more and I've come up with a lot of confusing data. Is there another way to do this scrollpane stuff? I am baffled. Maybe someone else won't be. Here's what I've come up with:
There are two scroll panes side-by-side in my gui. The left one has a tree of stuff you can click on to see metadata about it in the left side. Here's some code I have for setting up the panes (partially):
So that's at the beginning. When it first sets up the panels it always tells me:
Value of scrollbar is 0
Value of scrollbar is 0
That's right because the default is for there to be no vertical scrollbar unless the text stretches it out. Since there's no text yet, no scrollbar. Thus its value is 0.
Then I have added this to the code that runs when you click something on the left. I tried all _kinds_ of stuff to get it to behave:
But nothing works. The scroll bar stays not at the very bottom, but one or two pixels away, exactly at the bottom of the final character. Here's some output:
Value of scrollbar is 0 <---Initial values
Value of scrollbar is 0
Value of scrollbar before value changed is 0 <---After I clicked something
Value of scrollbar after value changed once is 0
Maximum is 295
Minimum is 0
Value of scrollbar after value changed twice is 0
Value of scrollbar before value changed is 252 <---The 2nd thing clicked
Value of scrollbar after value changed once is 0
Maximum is 295
Minimum is 0
Value of scrollbar after value changed twice is 0
Value of scrollbar before value changed is 86 <---Dragged the s.b. to the
Value of scrollbar after value changed once is 0 <---middle then clicked
Maximum is 295
Minimum is 0
Value of scrollbar after value changed twice is 0
If you take out setting the size of the JEditorPane to 295 and just let it figure out its own size it will say that the value of the scrollbar is 25 or 40 depending whether you add on another "Y" or not. That is, it sets the size and scroll bar value to match the amount of text.
I don't get why it wants to be at the bottom but at this point I am so baffled that I am willing to trash this idea and try another way. Is there another elegant way to do this?
Thanks,
Rebecca