0
我在更新JavaFX UI時遇到問題 - 我想在已經顯示的場景中更新線條圖和一些標籤。 我的任務是做一些計算(在其他類中調用返回數據的函數)並將更新後的系列添加到圖表。JavaFX中的實時更新LineChart
下面的代碼(這是一個循環)會出現什麼我想要做的:
//double x - x value of the point i want to add to my chart
//double y - y value of the point i want to add to my chart
//string s - some result from function
mySeries.getData().add(new XYChart.Data(x, y));
someLabel.setText(s);
我的程序凍結,一段時間後,只給出最終的解決辦法,但我希望看到在點圖表完全在添加之後,而不是在執行結束時。如果進程太快,我想添加Thread.sleep(1000),然後將下一個點添加到圖表。
我知道它與線程,併發和任務有關,但我還沒有找到解決方案。我試圖使用我在這裏找到的一些代碼,但仍然不知道正確的答案。
你正在做大量的工作在主線程上。 – Sedrick