java如何专注于BorderLayout中特定JPanel的键盘处理
在获取小部件焦点以在Java Swing BorderLayout的面板中启用键盘处理方面,我遇到了一些问题。我能够获得北面板的焦点,然后我的键盘处理程序就会启动。然而,如果我试图为布局的南面板或中心面板请求焦点,它根本不起作用。唯一似乎能够获得焦点的小组是北小组。有人知道为什么吗?这是按边界布局设计的吗
现在,我尝试从各种面板获取焦点的原因是,出于某种原因,当焦点设置为北面板时,似乎每隔一段时间键盘处理程序设置为在某些键上注册输入似乎根本不会启动。就好像他们不在那里。所以我想我会简单地使用布局中的另一个面板作为键盘输入的焦点,看看会发生什么,现在看来这个选项也不起作用
有人有什么想法吗
谢谢
# 1 楼答案
不是直接的回答,但我不能在评论中发布代码
我用的是
测试不同组件和外观的各种绑定