如何在Swing Java中设置Tab顺序? [英] How to set the Tab Order in Swing Java?
问题描述
我想知道如何在Swing界面中调整Tab顺序。我找到了一个例子,它表明这种方法可以解决这个问题,但它似乎已被弃用而且无法正常工作。
I want to know how to adjust the Tab order in a Swing interface. I found an example and it showed this method should do the trick but it seems that it's deprecated and not working.
getCombox("cmbFrom").setNextFocusableComponent(getCombox("cmbTo"));
注意: - 下面的方法返回带有Argument名称的Combox对象。如果有人知道如何使用Netbeans IDE,它会很棒。我在Eclipse WindowBuilder中找到了一种方法,但在Netbeans IDE中没有。谢谢。
Note :- Below method returns a Combox object with the Argument name. If someone knows how to do it with Netbeans IDE it would be great. I found a way to do it in Eclipse WindowBuilder but not in Netbeans IDE. Thank you.
getCombox(String s)
推荐答案
You can use the setFocusTraversalPolicy
in your container.
FocusTraversalPolicy
类是抽象的,您需要实现几个方法来返回容器的组件焦点顺序。它可以使用Tab和Shift + Tab。
FocusTraversalPolicy
class is abstract and you need implement few methods which will return the container's component focus order. It will work with Tab and Shift + Tab.
这篇关于如何在Swing Java中设置Tab顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!