Reputation: 1836
I have a TextArea
element which itself has a scroll bar and a separate ScrollPane
which has a scroll bar. How can i make one of the scroll bars match their position with the other one?
I have been looking up methods for acquiring the position of a scroll bar.
For ScrollPane
there is .getVvalue()
which returns a double from 0 to 1. Basically like a percentage value of sort.
For TextArea
there's .getScrollTop()
which also returns a double but it's maximum value is unknown pretty much unless you manually scroll the bar down to find out the position at the very bottom.
Since they both return different values I would have to know the maximum position for both of them.
Upvotes: 1
Views: 370
Reputation: 1738
A TextArea
has one child, which is its ScrollPane
. The percentage scroll can therefore be found as
((ScrollPane) textArea.getChildrenUnmodifiable().get(0)).getVvalue()
Hope this helps!
Upvotes: 2