我想在按下按钮后显示一个标签,但在按钮所做的操作完成后,我想隐藏标签。
这就是我试图做的
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)
代码根本不显示标签。