java Window 类不调度按键事件?
我扩展了 Window 类来创建 MetroWindow 类,它与普通 Window 类似,只是看起来更好一些。
当我向其中添加文本字段时,当我敲击键盘时,我会听到嘟嘟声,并且文本字段中没有显示任何字母。如果我不扩展 Window,而是扩展 JFrame,则 TextField 能够正确接收击键。
我想继续为我的 UI 扩展 Window,但我希望在我的 TextField 上接收正确的击键。我该如何做到这一点 - 调度击键、创建侦听器...?
I have extended the class Window to create the MetroWindow class, which is like the normal Window except that it is looks nicer.
When I add a TextField to it, I hear beep beep when I hit my keyboard and no letters are shown in the TextField. If, instead of extending Window, I extend JFrame, the TextField are able to receive keystrokes correctly.
I want to keep extending Window for my UI, but I would like to receive the correct keystrokes on my TextField. How do I do this - dispatch keystroke, create listeners... ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很抱歉为我自己的问题提供答案,但是万一有人正在寻找解决方案......
我所做的是扩展 JFrame 而不是 Window。
然后我设置 JFrame.setUndecorated(true);
这隐藏了我正在寻找的工具栏。
Sorry for providing an answer to my own question, but In case someone is looking for a solution...
What I did was to extend JFrame instead of Window.
I then set JFrame.setUndecorated(true);
this hides the toolbar which is what I was looking for.