小编spo*_*oke的帖子

任务完成后如何在javafx中显示然后隐藏标签

我想在按下按钮后显示一个标签,但在按钮所做的操作完成后,我想隐藏标签。

这就是我试图做的

    final Label loadingLabel = new Label();
    loadingLabel.setText("Loading...");
    loadingLabel.setFont(Font.font("Arial", 16));

    BorderPane root = new BorderPane();
    root.setRight(label);
    root.setLeft(button);
    root.setCenter(loadingLabel);
    loadingLabel.setVisible(false);

final Button printButton = new Button("Print part");
    printButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            loadingLabel.setVisible(true);
            //here are some computations
            loadingLabel.setVisible(false);
        }
    }
Run Code Online (Sandbox Code Playgroud)

代码根本不显示标签。

user-interface label javafx

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

javafx ×1

label ×1

user-interface ×1