JavaFX任务updateMessage绑定到附加的textArea

时间:2019-01-16 12:16:40

标签: javafx javafx-8

运行任务后台并返回更新消息。并发绑定的textarea更新正在运行。但是我希望textarea追加更新值。你能帮我吗?

我尝试使用Platform.update,但不是必需的,它不起作用。

 Task task = new Task<Void>() {
            @Override public Void call() {

                try{
                    socket=new Socket("localhost",8000);
                    BufferedReader bufferedReader = new BufferedReader(new 
                    InputStreamReader(socket.getInputStream()));
                    outputStream= socket.getOutputStream();
                    printWriter =new PrintWriter(outputStream);


                        while (true)
                        {
                             msg = bufferedReader.readLine();
                              updateMessage(msg);      
                        }

                }catch (Exception e)
                {
                }

                return null;
            }
        };
      responseArea.textProperty().bind(task.messageProperty());
        new Thread(task).start();

0 个答案:

没有答案