Multiline Text output in javafx


Question

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.

1
0
9/27/2017 12:42:44 PM

Accepted Answer

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.

2
7/18/2014 12:00:09 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon