I need to select text and move caret to the beginning of the selection. This is my code:
public class JavaFxTest7 extends Application {
private final CodeArea codeArea = new CodeArea();
@Override
public void start(Stage stage) {
this.codeArea.appendText("Some text is here.");
VBox.setVgrow(codeArea, Priority.ALWAYS);
codeArea.selectRange(0, 4);
codeArea.moveTo(0);
codeArea.requestFollowCaret();
Scene scene = new Scene(new VBox(codeArea), 600, 200);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
I want to select from 0 to 4 and move caret to 0. However, it doesn't work. At the same time, I don't have any problems when I need to move caret to selection end. Could anyone say how to do it?
I need to select text and move caret to the beginning of the selection. This is my code:
I want to select from 0 to 4 and move caret to 0. However, it doesn't work. At the same time, I don't have any problems when I need to move caret to selection end. Could anyone say how to do it?