This content has been marked as final. Show 1 reply
So, is the first the better/recommended way of using Tooltips?No.
Tooltip.install(Node, Tooltip) is provided so that you can set a tooltip on an arbitrary node.
control.setTooltip(new Tooltip()) is provided so that you can set a tooltip on a control.
Tooltip.install will also work on a control, but the setTooltip method will set a tooltip property on the control which you could listen to if you wanted.
In the end, it probably wouldn't make much difference either way which you used, but when using a control, the instance method seems more natural than the static method and it's easier to find when searching javadoc or using IDE based editing autocomplete suggestions.
The JavaFX designers could have provided a node.setTooltip method instead of also providing the Tooltip.install method, but that would have introduced a dependency between the base scene classes and the control classes, (which they wanted to avoid).