Reputation: 357
I have a javafx stage like this
As normal, I expect when user enter text and press tab key, it will focus to next text field for input. But my case is: when I enter FullName and press tab it will focus on Email field then Username, Password, Confirm Password.
What is wrong here?
Thanks!
Upvotes: 0
Views: 2156
Reputation: 82461
If you "move" the focus, it will go to the next child with focusTraversable
set to true
.
Since the order of the children is not important for their placement in GridPane
, this can lead to a focus traversal order, that is independent from Node
placement in the layout.
In your screenshot you can see that the TextField
in cell (1, 5)
is added before the TextField
in cell (1,2)
. To fix this, simply reorder the (focus traversable) children of the GridPane
ascending by row index using the Hierarchy View.
Upvotes: 1