2014-07-14 115 views
0

我在更新表格視圖中的值時遇到問題。逐行更新TableView javaFX

我有一個for循環,它更新我所有的行值。我使用StringProperty作爲我的模型類字段類型。當我更新單行時,它工作正常。但我的要求是我需要停止更新後每行1000毫秒。我試着在我使用了Thread.sleep(1000)for循環,其並沒有幫助:(

+0

你能發佈一些代碼,你已經嘗試過了嗎? – ItachiUchiha

回答

0

不要試圖操縱你的主題,將太複雜

只需使用時間表是這樣的:。

timer = new Timeline(new KeyFrame(Duration.millis(1000), new EventHandler<ActionEvent>() { 
     @Override 
     public void handle(ActionEvent t) { 
      //Pause your timer in order to update your row 
      timer.pause(); 

      //Do your update (increment your rowIndex inside) 
      updateRowMethod(rowIndex); 

      //Then launch the Timer and exit 
      timer.play(); 
     } 
    })); 

我使用暫停的方法,因爲你說你想要一個行版後等待1000毫秒。如果你只是想編輯的委每一秒,跳過暫停/播放部分。