如何检查 JTabbedPane 中的选项卡是否处于活动状态?
如何检查 JTabbedPane 实例中的选项卡是否处于活动状态,在选项卡(嵌套类)本身的类中而不是在封闭类中?
我知道有一个方法 booloean isEnabledAt(int index); ,但这个方法只能在封闭类中调用。而我想检查当前是否在选项卡类本身(嵌套类)中选择了该选项卡。
有人可以建议如何吗?
How can I check whether a tab in a JTabbedPane instance is active or not, in the class of the tab (nested class) itself and not in the enclosing class?
I know that there is a method booloean isEnabledAt(int index);
but this method can only be called in the enclosing class. Whereas I want to check whether the tab is currently selected within the tab class itself (nested class).
Can anybody please suggest how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这是一个老话题,但我在寻找类似(尽管略有不同)问题的解决方案时发现了它。
要确定选择了哪个选项卡,请使用
ChangeEvent
侦听器。这是一种在选择选项卡时执行操作的非常简单的方法。希望这对其他人有帮助,尽管这是一个老话题。I know that this is old topic, but I found it when looking for a solution to a similar (though slightly different) problem.
To determine what tab was selected, use a
ChangeEvent
listener. This is a very simple way to perform an action whenever a tab is selected. Hopefully this will help someone else, though this is an old topic.您的组件有一个 父组件,最终是
JTabbedPane
。JTabbedPane
具有类似getSelectedIndex()
或getSelectedComponent()
。Your component has a parent, eventually the
JTabbedPane
.JTabbedPane
has methods likegetSelectedIndex()
orgetSelectedComponent()
.