Resetting textArea length JavaFX

2019-08-19 07:10发布

问题:

I wrote server in C and client in Java. I used JavaFX for GUI. Everything works except that sometimes I get exceptions when textArea gets filled and receives more data before it gets reseted (probably cause of parallel threading). Actually there are 3 cases which occur "randomly":
1) Stucks/hangs and no exceptions are thrown.
2) NullPointerException (about Line Padding and Content Bounds [there's nowhere my code mentioned]).
3) IllegalArgumentException: Both width and height must be >= 0.
4) Exception about String text bounds.

Here's the code if it helps:

if(textArea.getLength() > 500) // I tried with > 2000, similar situations occur
    textArea.setText("");
command = textField.getText();
out.println(command); // out to socket
textField.setText("");

Btw, this GUI should represent basic Linux shell, so textArea should sometimes be able to receive large amount of data (such as netstat command). Thanks!

回答1:

It is an exact dublicate of your previous question but with more info, so not going to vote for closing. I asked you to post exception stacktrace in that previous question, but you mentioned there is no your code related lines in stacktrace, hence I also presume like you that it is a bug of textArea. So I suggest to try to use another component, for example a big Label with white background :), if it is solely for displaying purposes.



标签: javafx-2