Reputation: 574
I want to provide possibility to enter Chinese characters in JavaFX in Windows. This is my test code for TextArea:
public class Foo extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
var textArea = new TextArea();
textArea.setOnInputMethodTextChanged(e -> {
System.out.println("Event:" + e.getCommitted().length());
textArea.appendText(e.getCommitted());
});
VBox.setVgrow(textArea, Priority.ALWAYS);
var root = new VBox(textArea);
var scene = new Scene(root, 400, 400);
primaryStage.setScene(scene);
primaryStage.show();
}
}
And this is the result:
How it works:
I don't know Chinese but I tried IME with Firefox and it works without #5
. Could anyone say how to do it without making user press Enter for every symbol?
Upvotes: 4
Views: 70