I have a simple login window, and i want to show a JFXSpinner (like a loader) when i send the login request. For that, i have created a JFXSpinner object and initially i maked it invisible (setting the visibility value to false) and when the user click on the LOGIN button i want to show the spinner before sending the request and hide it again after finishing the request. The problem is : i can't show my JFXSpinner. can anyone help me please ?
This is my login methode
//loader : is my JFXSpinner object
public void login(ActionEvent event)
{
Task task = new javafx.concurrent.Task<Void>()
{
@Override
protected Void call() throws Exception
{
loader.setVisible(true);
if(Compte.login(username.getText(), password.getText()))
{
System.err.println("It's okey");
}
else
{
//TODO
}
loader.setVisible(false);
return null;
}
@Override
protected void succeeded()
{
loader.setVisible(false);
}
@Override
protected void failed()
{
loader.setVisible(false);
}
};
Thread thread = new Thread(task, "My Task");
thread.setDaemon(true);
thread.start();
}