I want to show some text in my program and I tried with TextArea
. However, the text shown is changeable. How can I make the text read only?
To set the prompt text for a TextField use the setPromptText method: txtFld.
In this article, we show how to add prompt text to a text field in JavaFX. A prompt text is text that appears in a text field when it is first load but that disappears when a user starts typing into the text field.
A Text is a geometric shape (like a Rectangle or a Circle), while Label is a UI control (like a Button or a CheckBox). In Swing, geometric shapes were restricted to the painting mechanism, while in JavaFX they can be used in more generic ways. And you can use a Text clipping, giving the node shape by the text.
I did it like this:
@FXML
private TextArea myText;
and then added the following code to initialise()
:
myText.setEditable(false);
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