Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我制作一个 JFrame 时,JFrame 顶部的东西会自动“选中”。
JFrame/JDialog 顶部的所有内容都将被“选中”,例如 JButton、JTextField、...。如何在不使用鼠标单击其他区域的情况下取消选择(使用一些代码)它。
jButton1 表示 JFrame 顶部的东西(我使用 Snagit 捕获它,但按钮自动“取消选择”)
请帮我。谢谢
在您使用setVisible(true). 使用此行在 JFrame 上设置焦点请求:
setVisible(true)
frame.requestFocus()
requestFocus在您要在启动应用程序后选择的对象的主函数调用方法中。
requestFocus