2017-03-04 22 views
1

如何在Codename One中暫停啓動畫面?如何暫停Codename One中的啓動畫面?

似乎例子(本機演示)使用replaceAndWait(...)方法,但在我的情況我什麼都沒有更換,但我只是想在屏幕等待幾秒鐘。

我試圖使用Thread.wait(n)但它崩潰。

謝謝!

回答

3

您可以在StateMachine.java文件中的processBackground()裏調用UITimer來延遲啓動屏幕。

如果您未使用StateMachine(在GUI生成器中未創建Splash),請延遲下一個表單,以便在您的主要類中使用您的splash splash方法中使用UITimer來顯示相同​​的方法。

@Override 
protected boolean processBackground(final Form f) { 
    //depends on your splash form's name 
    if ("Splash".equalsIgnoreCase(f.getName())) { 
     new UITimer(() -> { 
      //show your next form here 
     }).schedule(4000, false, f);// set the time to a longer time, currently 4 seconds 
    } 
    return false; 
}