首页 > 解决方案 > 设置禁用某些窗格以指定时间

问题描述

我在 BorderPane 上有井字游戏。在左侧我有简单的聊天。我想设置可能性在 5 秒后第一次发送另一条消息,即我想为聊天设置禁用 5 秒,但应用程序的其他部分必须工作。我怎样才能做到这一点。

@FXML
private GridPane mainGridPane; //here game

@FXML
private GridPane smileGridPane; //this I want stop for five second

标签: javafx

解决方案


PauseTransition带有onFinished重新启用窗格的处理程序的 A 将起到作用:

smileGridPane.setDisable(true); // disable target pane
PauseTransition pause = new PauseTransition(Duration.seconds(5));
pause.setOnFinished(evt -> smileGridPane.setDisable(false)); // reenable target pane
pause.play();

推荐阅读