KD Palekar
KD Palekar

Reputation: 23

How to Enable or Disable the buttons in JavaFX form?

I am working on my project and there are some buttons that I wanted to disable at the time of running. So I disabled them but How can I enable them back when I wanted to.?? Because there is no setEnable() property.

Please tell me how can I enable the buttons?

enter image description here

enter image description here

Upvotes: 2

Views: 9497

Answers (1)

DVarga
DVarga

Reputation: 21799

You are looking for the disableProperty:

Defines the individual disabled state of this Node. Setting disable to true will cause this Node and any subnodes to become disabled. This property should be used only to set the disabled state of a Node. For querying the disabled state of a Node, the disabled property should instead be used, since it is possible that a Node was disabled as a result of an ancestor being disabled even if the individual disable state on this Node is false.

setDisable(true); // will disable the Button
setDisable(false); // will enable it again

Upvotes: 5

Related Questions