Text input fields in Swing stop working on OS X when holding keys down

本小妞迷上赌 提交于 2019-12-02 04:16:49

It seems to have been a problem with OS X itself. After a restart of my Mac, the problem is now gone.

I have been having this exact issue for quite a while. I was frustrated that suddenly all input text fields in my JFrame would stop working. It was only today that I found it to be related the apple's popup for accented characters. For me the issue only happens when I long press one of the keys that has associated accented characters (for example: a, c, e, u, n, ...) while the focus in the frame is on one the components that doesn't have a text input (e.g. a button or a panel). Still looking for a proper solution to fix it programmatically within in the program itself, but here is a workaround I accidentally found:

Whenever the issue happens and the keys stop working, I first click on any "text field" in the frame to make it focused, then I hold any one of those keys with accent popup (e.g. "a" key), until the popup show. Then I just hit escape and from there after all the keys start working again.

Strangely, once I go through this once, the issue doesn't ever happen again on that frame until the next time the frame is closed and opened.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!