java jframe tab,如何在Swing Java中设置Tab顺序?

在Swing界面中,要改变Tab键的焦点顺序,可以使用FocusTraversalPolicy。你需要创建一个自定义的FocusTraversalPolicy类,并实现其方法来定义组件的焦点顺序。这将适用于Tab和Shift+Tab切换。在NetBeans IDE中,可以尝试类似的方法来设置组件的焦点流转顺序。
摘要由CSDN通过智能技术生成

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"));

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 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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值