我正在尝试使用一个小进度条在 JavaFX 中创建一个登录页面。但是每次我想检查凭据时,任务都会失败并将我扔到 setOnFailed() 方法中。我不知道是什么让它改变了它的状态或如何使它工作。
到目前为止,这是我的代码:
public class Login extends Base_controller implements Initializable{
private ProgressBar pb = new ProgressBar();
private TextField username;
private PasswordField password;
public void start(Stage primaryStage) throws Exception {
// Setting structure and components
Label username_lbl = new Label();
Label password_lbl = new Label();
username_lbl.setText("Username:");
password_lbl.setText("Password:");
username = new TextField();
password = new PasswordField();
//some code
VBox root = new VBox();
root.setAlignment(Pos.CENTER);
root.getChildren().addAll(container0, container1, container2, container3);
root.setSpacing(30);
// button action listener
test.setOnAction(e->{
Platform.runLater(() -> {
root.getChildren().add(pb);
}); …Run Code Online (Sandbox Code Playgroud)