Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有进度指示器的JavaFX奇怪行为_Java_Javafx 2_Javafx - Fatal编程技术网

带有进度指示器的JavaFX奇怪行为

带有进度指示器的JavaFX奇怪行为,java,javafx-2,javafx,Java,Javafx 2,Javafx,我正在做一个登录屏幕,我想在执行用户身份验证过程时显示一个进度指示器。 我正在做这样的事情 // Handler for Button[fx:id="login"] onAction public void handleLogin(ActionEvent event) { // Show loading indicator showLoadingImg(); // User authentication String userName = user.getTex

我正在做一个登录屏幕,我想在执行用户身份验证过程时显示一个进度指示器。 我正在做这样的事情

// Handler for Button[fx:id="login"] onAction
public void handleLogin(ActionEvent event) {
    // Show loading indicator
    showLoadingImg();

    // User authentication
    String userName = user.getText();
    String password = psw.getText();

    OrdLogin ord = new OrdLogin();
    ord.setUserName(userName);
    ord.setPassword(password);
    ord.run();

    Authentication auth = orden.getInfoAutenticacion();
    if(auth == null){
        // Remove the loading indicator
        contProgress.getChildren().remove(1);

        // Show an error message
        msgError.setText("Incorrect password/user");
        msgError.setPrefHeight(Region.USE_COMPUTED_SIZE);
    } else {
        // login successful!
                    ...
    }
}

private void showLoadingImg() {     
    // Show loading indicator
    ProgressIndicator progress = new ProgressIndicator();
    contProgress.getChildren().add(progress);
}
如果在initialize方法中运行showLoadingImg(),指示器将正确显示,但在handleLogin中运行showLoadingImg()时,指示器将不显示。
有什么线索吗?

如果auth为null,则将从contProgress容器中删除进度指示器。您是否对软件进行了调试以查看是否发生了这种情况?

是。Auth不为空。当我调试并碰巧发现runLater方法从未按预期的方式读取时。可能线程与主线程冲突,我不知道