There are two methods available for calling when inheriting from javafx.scene.Node: (I am showing off the current 8u66 Oracle implementation)
setDisable(boolean)
public final void setDisable(boolean value) {
disableProperty().set(value);
}
setDisabled(boolean)
protected final void setDisabled(boolean value) {
disabledPropertyImpl().set(value);
}
Which one should I call when inheriting from javafx.scene.Node?
It depends a bit on the context, but you almost certainly want to call setDisable(...).
In JavaFX, a node is rendered as disabled, and ignores any user input, if its disable property is true, or if the disable property is true for any ancestor in the scene graph. The disabled property, which is a read-only property for clients of the node, reflects this overall state: i.e. disabled is true if and only if disable is true for this node or for any of its ancestor (container) nodes.
So to disable a node, you should typically call setDisable(true);. In a custom subclass of Node, you should only call setDisabled(true); to enforce the rule described above. Note that the superclass implementation will already enforce this rule, so unless you are doing something very complex (I can't even really see a use case), you will not need to call setDisabled(...).
You want to use
setDisable, notsetDisabled.setDisableis apublicmethod for disabling a node,setDisabledis aprotectedmethod used only by internal implementations.
Quoted from this comment by user @jewelsea.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With