Reputation: 7435
I have a JPanel
with components added with absolute locations (ie. "pos x y"), and the layout is effectively two columns of textfields. What I would like to achieve would be for Tab to shift the focus to the next component vertically, so as to traverse the first column, then the second. At the moment it does it horizontally. I've tried to extend FocusTraversalPolicy
but what annoyed me was that you have to add it to the JFrame
and not just the panel itself - unless that's incorrect?
How can I achieve this? Thanks.
Upvotes: 1
Views: 379
Reputation: 3635
As far as I know the default focus traversal cycle is the natural order of the childcomponents in a container, i.e. the order in which they were added to the container. I don't know MigLayout very well, but if you manage to add the components vertically, the focus traversal might follow.
You can set a FocusTraversalPolicy to any Container, however, Swing will only use it when you call setFocusTraversalPolicyProvider(true) on the same Container.
Upvotes: 2