Multiline Text output in javafx

I need to output 5-8 lines to my window. I managed that with a TextArea, BUT, i don't want the user to be able to write inside it, AND I also can't use my keyboard to navigate between buttons and other elements on the page.

Lets say that there is a String named text, which field type do you think i should write it out into? Text is good but only lets me use a single line.

Text  actiontarget3;
String text = new String(" something  \n  Second line something");
actiontarget4.setText(text);

Because I use FXML to design the menu page, the relevant part is:

  <Text  fx:id="actiontarget3"
  GridPane.columnIndex="1" GridPane.rowIndex="1"/>

Basically, I managed to get the info from a ping test, added it to an ArrayList<String> and I want to display the results on the Graphic User Interface. But the above example covers my problems without having to copy paste here the entire code.

Upvotes: 0

Views: 7635

Answers (1)

Zach
Zach

Reputation: 4792

You can make it so a TextArea is not editable.

JTextArea ta = new JTextArea();
ta.setEditable(false);

You may also want to look into using a JTextPane.

Upvotes: 2

Related Questions