This discussion is archived
1 Reply Latest reply: Dec 6, 2012 3:22 PM by jsmith RSS

Difference between Tooltip.install(Node, Tooltip) and node.setTooltip()?

csh Journeyer
Currently Being Moderated
Hi,

what is there a difference between using

Tooltip.install(Node, Tooltip);

and

node.setTooltip(new Tooltip());

??

Usually I use the latter, but now I have a case where it doesn't work (in a graphic of a TableCell), so tried Tooltip.install and it works.

So, is the first the better/recommended way of using Tooltips?
  • 1. Re: Difference between Tooltip.install(Node, Tooltip) and node.setTooltip()?
    jsmith Guru
    Currently Being Moderated
    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).

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points