重置textArea长度JavaFX [英] Resetting textArea length JavaFX

查看:95
本文介绍了重置textArea长度JavaFX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用C语言编写了服务器,并用Java编写了客户端.我将JavaFX用于GUI.一切正常,除了有时当textArea被填充时,我会收到异常消息,并且在重置之前会收到更多数据(可能是并行线程引起的).实际上,有3种情况是随机"发生的:
1)卡住/挂起,不会抛出异常.
2)NullPointerException(关于换行和内容边界[我的代码无处提及]).
3)IllegalArgumentException:宽度和高度都必须> =0.
4)关于字符串文本边界的异常.

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("");

顺便说一句,该GUI应该代表基本的Linux shell,因此textArea有时应该能够接收大量数据(例如netstat命令). 谢谢!

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!

推荐答案

它是您上一个问题的精确副本,但有更多信息,因此请不要投票赞成结束.我要求您在上一个问题中发布异常stacktrace,但是您提到在stacktrace中没有与代码相关的行,因此我也像您一样假定它是textArea的错误.因此,如果它仅用于显示目的,我建议尝试使用其他组件,例如带有白色背景的大Label:).

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.

这篇关于重置textArea长度JavaFX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆