I have a form that populates an area at the top with error
messages when it validates. The form is long and often scrolls off
the bottom of the page. I want the user to be able to click on the
error message and then be taken to the field with the error.
This is what I got so far. I have a VBox that contains a
Form. This is the snipped of code that responds to the user
clicking on the error text. It finds the field just fine. But if it
scrolls off the page I cannot scroll the field into view.
I found this eventually. It is such a simple thing I am
surprised that nobody here knew the answer. One clue is that the
scrollbar position is not the position of the scrollbar on the
scrollbar track. It is the number of pixels the page has scrolled
from the top of the page. So if you want to scroll to some item all
you have to do is set its parent's verticalScrollbarPosition or
horizontalScrollbarPosition to the item's respective y or x. Do
something like this: