4
I have a Stage
Main that is my Login:
In the FXML
of that Stage I have a Region
and a ProgressIndicator
with the property setVisible(false)
After successfully logging into the application the intention would be to display this Region
and the ProgressIndicator
as a thread started the application, but what happens is that after logging in the thread starts running by loading the application, but the Region
and the ProgressIndicator
, are not visible.
My thread
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();
I tried to make two threads: one to load the system and one to update
the ProgressIndicator
while the system is not loaded, but unsuccessfully,
does not generate Exception
, I’ve tried several ways.
What I realized in my various attempts:
One Thread is started and the other is not (Starts only the Thread that loads the system).
To Thread does not start.
To Thread initiates but the
ProgressIndicator
gets stuck, doesn’t get excited.
Log-in snippet:
@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();
}
}
After login successfully how to display the ProgressIndicartor
while the system is loaded in the background?