I need to set the caret position manually in my code.
There is a getCaretPosition()
under javafx.scene.control.TextInputControl
but there is no setter method.
How can I set the caret position?
You can use following statement in order to make text-area object non-editable with auto scrollbar: textAreaObjectName. setEditable(false);
TextField class is a part of JavaFX package. It is a component that allows the user to enter a line of unformatted text, it does not allow multi-line input it only allows the user to enter a single line of text. The text can then be used as per requirement.
A JavaFX TextArea control enables users of a JavaFX application to enter text spanning multiple lines, which can then be read by the application. The JavaFX TextArea control is represented by the class javafx. scene.
Creating a Text FieldLabel label1 = new Label("Name:"); TextField textField = new TextField (); HBox hb = new HBox(); hb. getChildren(). addAll(label1, textField); hb. setSpacing(10);
TextArea ta = new TextArea();
ta.setText("1234567890");
ta.positionCaret(4);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With