在 JTextfield 中保留键盘布局?
简单的例子:2 个JTextFields
,一个用于西班牙语单词,另一个用于其翻译。 有没有办法保留每个 JTextField 的键盘布局,以便用户不必来回切换?
TIA。
Simple example: 2 JTextFields
, one for a spanish word another one for it's translation.
Is there a way to preserve keyboard layout per JTextField
so that the user wouldn't have to switch back and forth?
TIA.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,此演示代码使用每个文本字段中选定区域设置的键盘布局:在
安装了 EN 和 ES 键盘布局的 Windows XP Home 上进行测试(通过控制面板 > 区域和语言选项 > 语言 > 详细信息...) 。 有关更多详细信息,请参阅 Java 输入法框架 。
Yes, this demo code uses the keyboard layout for the selected locales in each text field:
Tested on Windows XP Home with EN and ES keyboard layouts installed (via Control Panel > Regional and Language Options > Languages > Details...). See the Java Input Method Framework for more details.
不,键盘布局由操作系统或桌面环境管理。
No, keyboard layouts are managed by the OS or desktop environment.
如果您确切地知道相关西班牙语键盘的布局,理论上您可以自己处理 KeyEvents,将它们翻译成适当的字符。 然而,这并不是一件容易的事。 您最终可能会自己将字符插入文本字段。
If you know exactly the layout of the Spanish keyboard in question you could theoretically process KeyEvents yourself, translating them into the appropriate character. However this would not be an easy thing to do. You would probably end up inserting characters into the textfields yourself.