第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

為什么我在JavaFX上得到j(luò)ava.lang.IllegalStateException

為什么我在JavaFX上得到j(luò)ava.lang.IllegalStateException

搖曳的薔薇 2019-08-02 17:20:19
為什么我在JavaFX上得到j(luò)ava.lang.IllegalStateException“不在FX應(yīng)用程序線程上”?我有一個(gè)TableView具有附加偵聽器的應(yīng)用程序,因此一旦檢測(cè)到更改就會(huì)刷新,但問題是我得到了java.lang.IllegalStateException: Not on FX application thread; currentThread = Smack Listener Processor (0)。這是我的代碼:/**  * This function resets the pagination pagecount  */public void resetPage() {     try {         System.out.println("RESET");          int tamRoster = this.loginManager.getRosterService().getRosterList().size();         paginationContactos.setPageCount((int)(Math.ceil(tamRoster*1.0/limit.get())));         int tamEnviados = this.loginManager.getRosterService().getEnviadasList().size();         paginationEnviadas.setPageCount((int)(Math.ceil(tamEnviados*1.0/limit.get())));         int tamRecibidas = this.loginManager.getRosterService().getRecibidasList().size();         paginationRecibidas.setPageCount((int)(Math.ceil(tamRecibidas*1.0/limit.get())));     } catch (Exception e) {         e.printStackTrace();     }}public void doSomething () {         this.loginManager.getRosterService().getRosterList().addListener(new ListChangeListener<RosterDTO>() {             @Override             public void onChanged(                     javafx.collections.ListChangeListener.Change<? extends RosterDTO> c) {                 // TODO Auto-generated method stub                 resetPage();                 while (c.next()) {                     if (c.wasPermutated()) {                         System.out.println("PERM");                     } else if (c.wasUpdated()) {                         System.out.println("UPD");                     } else {                         System.out.println("ELSE");                     }                 }             }          });}它進(jìn)入resetPage方法,我得到了那個(gè)異常。為什么會(huì)這樣?我該如何解決?提前致謝。
查看完整描述

2 回答

?
有只小跳蛙

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超8個(gè)贊

無法從非應(yīng)用程序線程直接更新用戶界面。相反,使用Platform.runLater()Runnable對(duì)象中的邏輯。例如:

Platform.runLater(new Runnable() {
    @Override
    public void run() {
        // Update UI here.
    }});

作為lambda表達(dá)式:

// Avoid throwing IllegalStateException by running from a non-JavaFX thread.Platform.runLater(
  () -> {
    // Update UI here.
  });


查看完整回答
反對(duì) 回復(fù) 2019-08-02
  • 2 回答
  • 0 關(guān)注
  • 1087 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)