Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX how to show read-only text?

Tags:

javafx

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?

like image 304
user3034281 Avatar asked Nov 25 '13 22:11

user3034281


People also ask

How do I set the prompt text in JavaFX?

To set the prompt text for a TextField use the setPromptText method: txtFld.

What is prompt text in JavaFX?

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.

What is the difference between text and label in JavaFX?

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.


1 Answers

I did it like this:

@FXML
private TextArea myText;

and then added the following code to initialise():

myText.setEditable(false);
like image 53
Gustaf Svensson Avatar answered Oct 06 '22 09:10

Gustaf Svensson