2016-11-27 30 views
0

從java swing我用來顯示長時間運行任務的模態對話框。後臺線程不時更新對話框上的狀態標籤和進度條。是否可以更新vaadin模態窗口的組件?

隨着vaadin模態窗口,我不能改變任何東西從後臺線程,我甚至不能關閉窗口。

這是預期的行爲還是我做錯了?

編輯:其實我似乎無法更新窗口,即使它是非模態的。

Window window = new Window(); 
// window.setModal(true); 

VerticalLayout layout = new VerticalLayout(); 
Label label = new Label("0"); 
layout.addComponent(label); 
window.setContent(layout); 
window.center(); 

new Thread(() -> { 
    try 
    { 
    Thread.sleep(1000); 
    System.out.println("update 1"); 
    UI.getCurrent().access(() -> label.setValue("1")); 
    Thread.sleep(1000); 
    System.out.println("update 2"); 
    UI.getCurrent().access(() -> label.setValue("2")); 
    Thread.sleep(1000); 
    System.out.println("update 3"); 
    UI.getCurrent().access(() -> label.setValue("3")); 
    Thread.sleep(1000); 
    System.out.println("close"); 
    UI.getCurrent().access(() -> window.close()); 
    } 
    catch(InterruptedException e) 
    { 
    System.out.println(e); 
    } 
}).start(); 

UI.getCurrent().addWindow(window); 

編輯2:我只是碰到了vaadin push concept迷迷糊糊的,這可能就是我在這裏失蹤。

回答

0

原因是我沒有配置vaadin push

將vaadin-push依賴項和@Push註釋添加到我的主UI後,它開始工作。

現在開始到next problem ...

相關問題