2014-11-25 62 views
0

我有一個主舞臺是我的登錄 FXML在這個階段有一個地區,並與物業調用setVisible一個ProgressIndicator(假)JavaFX的螺紋鎖固系統

後成功登錄到應用程序的意圖是以下幾種觀點這個區域和ProgressIndicator在一個線程啓動應用程序的時候,但是會發生的事情是,在線程開始旋轉加載應用程序之後,Region和ProgressIndicator不可見。

我的主題

Task t = new Task() { 

    @Override 
    protected Object call() throws Exception { 

     Platform.runLater(() -> { 
      try { 

       new SisgeFX().start(); 
      } catch (IOException ex) { 
       Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex); 
      } 
     }); 
     return null; 
    } 
}; 
region.visibleProperty().bind(t.runningProperty()); 
pi.visibleProperty().bind(t.runningProperty()); 
Thread th = new Thread(t); 
th.start(); 

我試圖使兩個線程一個引導系統,另一個更新ProgressIndicator而沒有加載系統,但沒有成功,不產生Excepetion,已經在嘗試幾種方法。

我在幾次試圖實現什麼:

1 - 一個線程並開始和其他不(只啓動加載系統中的線程)。

2 - 線程無法啓動。

3 - Tread開始,但ProgressIndicator被鎖定,它不是animanda。

摘錄登錄:

@FXML 
    private void sysLogin() { 
    String user = ctfUserLogin.getText(); 
    String pass = ctfPassLogin.getText(); 
    LoginDAO loginDAO = DAOFactory.make(LoginDAO.class); 
    Login login = loginDAO.getLogin(user, pass); 

    if (login != null) { 
     runThread(); // aqui chamo a Thread postado acima. 
     ctfPassLogin.setStyle(null); 
     ctfUserLogin.setStyle(null); 
    } else { 
     ctfPassLogin.clear(); 
     ctfUserLogin.clear(); 
     ctfPassLogin.setStyle("-fx-border-color:red;"); 
     ctfUserLogin.setStyle("-fx-border-color:red;"); 
     //new ShakeTransition(vBox).play(); 
     new WobbleTransition(vBox).play(); 
     //new TadaTransition(vBox).play(); 
    } 

} 

如何顯示ProgressIndicator在系統加載?

+0

存在着類似的問題:http://stackoverflow.com/questions/27090426/progressbar-in-javafx-does-not-update-in-onaction-block/27092945#27092945。也許這有助於...... – 2014-11-25 17:02:04

+0

謝謝,但不適合我。 – DOM 2014-11-26 09:24:49

回答

0

在方法開始時,試試下面的語句。

Platform.setImplicitExit(false);