我有一个JPanel
添加了绝对位置的组件(即“pos x y”),并且布局实际上是两列文本字段。我想要实现的是Tab将焦点垂直转移到下一个组件,以便遍历第一列,然后是第二列。目前它是水平的。我试图扩展FocusTraversalPolicy
,但让我恼火的是你必须将它添加到JFrame
而不只是面板本身 - 除非这是不正确的?
我怎样才能做到这一点?谢谢。
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.