JTabbedPane - 选项卡更改后聚焦最后一个聚焦组件
更改选项卡时,JTabbedPane 始终将焦点集中在选项卡内的第一个可聚焦组件。 我怎样才能改变它的行为,以便它要么聚焦最后一个聚焦的组件,要么根本不聚焦? 之后调用 requestFocus 不是一个选项,因为 JTabbedPane 绝对不能将焦点设置在错误的字段中。
When changing tabs, JTabbedPane always focuses the first focusable Component inside the tab.
How can I change its behaviour so that it will either focus the last focused component or none at all?
Invoking requestFocus afterwards is not an option because JTabbedPane must not set the focus in the wrong field at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下:记住最后一个焦点组件。
您需要跟踪每个选项卡中哪个组件具有焦点。然后,当选择选项卡时,您需要将焦点更改到适当的组件。这是从上面的链接中获取的代码:
Take a look at: Remembering last focused component.
You need to keep track of which component has focus in each tab. Then when a tab is selected, you need to change focus to the appropriate component. Here is the code taken from the link above:
基本上,这可以在一个 顶级容器 中正确运行
basically this works inside one Top-Level Container correctly