For controls
The controls have a setter for tooltips . So for controls use this.
To set a tooltip in a control:
btnSettingsOk.setTooltip(new Tooltip("OK Button"));
To remove a tooltip on a control:
btnSettingsOk.setTooltip(null);
For nodes that are not controls
Panels, shapes, and other layout nodes do not have a tooltip set (since tooltips are classified as controls, and JavaFX developers need to avoid dependency of common scene graph nodes on the control pack). However, these nodes can work with tooltips using the static install and uninstall .
This is pretty much Ikallas answer, although I would recommend using it only when the node type does not provide an explicit setTooltip method, even if it will also work for controls. The set method on controls is easier to use because the control contains a link to a tooltip, while for static uninstallation, your application is responsible for maintaining a link to a tooltip so that it can later be deleted.
To set a tooltip on a node that is not a control:
Tooltip okTooltip = new Tooltip("OK Button"); Tooltip.install(btnSettingsOk, okTooltip)));
To remove a tooltip from a node that is not a control:
Tooltip.uninstall(btnSettingsOk, okTooltip);
source share