JavaFX: How to disable a button for a specific amount of time?

后端 未结 4 1120
轻奢々
轻奢々 2021-01-13 10:48

I want to disable a button for a specific time in JavaFX application. Is there any option to do this? If not, is there any work around for this?

Below is my code in

4条回答
  •  Happy的楠姐
    2021-01-13 11:11

    The method to disable a JavaFX control is:

    myButton.setDisable(true);
    

    You can implement the time logic programmatically in any way you wish, either by polling a timer or by having this method invoked in response to some event.

    If you have created this button instance through FXML in SceneBuilder, then you should assign the button an fx:id so that its reference is automatically injected into your controller object during the loading of the scene graph. This will make it easier for you to work with in your controller code.

    If you have created this button programmatically, then you'll already have its reference available in your code.

提交回复
热议问题