将键盘输入与JavaFX中的TextField相关联 [英] Associate a keyboard input with a TextField in JavaFX

查看:651
本文介绍了将键盘输入与JavaFX中的TextField相关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用两个JavaFX TextField ,一个使用标准英语键盘/语言输入,另一个使用日语键盘/语言。

I am trying to have two JavaFX TextFields, one which takes input using a standard English keyboard/language, and the other using a Japanese keyboard/language.

此答案解决了Swing的问题,但JavaFX TextField 没有所需的 getInputContext()方法。

This answer addresses the problem for Swing, but the JavaFX TextField doesn't have the needed getInputContext() method.

我的计划是捕捉焦点事件并将 Locale 更改为日语,或关联特定的 Locale ,日语 TextField 。但是,我不知道如何实际实现其中任何一个。

My plan was to either catch a focus event and change the Locale to Japanese, or associate a specific Locale with the Japanese TextField. However, I don't know how to actually achieve either of these.

我怀疑Java 输入法客户端API

我正在使用Windows 8,但有一个独立于操作系统的答案会很好。

I am using Windows 8, but it would be nice to have a OS independent answer.

推荐答案

唯一的事情是接近我能找到的是:

The only thing that comes close that i could find was:

textfield.getText().regionMatches();

但是我不确定这是你要找的那个。

however im not sure that this is the one your looking for.

更新

我也找到了

txt_message.getText().format(Locale.JAPANESE, format, args)

这篇关于将键盘输入与JavaFX中的TextField相关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆