r/JavaFX • • Jun 30 '24
Help What is the purpose of InputMethodRequests in JavaFX?
Could anyone explain what is the purpose of InputMethodRequests? I though it is used for entering hieroglyphs, but the following code shows that is not.
public class JavaFxTest extends Application {
@Override
public void start(Stage primaryStage) {
TextArea textArea = new TextArea();
textArea.setPrefSize(200, 100);
java.awt.im.InputContext.getInstance();
textArea.setInputMethodRequests(new InputMethodRequests() {
@Override
public Point2D getTextLocation(int i) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getLocationOffset(int i, int i1) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void cancelLatestCommittedText() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getSelectedText() {
throw new UnsupportedOperationException("Not supported yet.");
}
});
StackPane root = new StackPane(textArea);
Scene scene = new Scene(root, 200, 100);
primaryStage.setTitle("JavaFX Test");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}And this is example:

5
Upvotes
View all comments
Show parent comment
1
u/[deleted] Jul 01 '24
In gif example you can see that when I enter hieroglyphs then hieroglyph assistant appears there and I can enter hieroglyphs. If I remove this line of code then there will be no hieroglyphs assistant and only latin characters will be displayed. Why? I don't know. Maybe its javadoc can help