2

Looking around, it seems that the general consensus for adding a Tooltip is through the Tooltip#install method:

Tooltip.install(button, new Tooltip("This is a tooltip"));

However, binding this to a button doesn't seem to do anything of the sort.

I'm using JavaFX scene builder and the button I want to have a tooltip added to is configured in my Controller class through @FXML tags.

This is the button in action:

enter image description here

How does one go about adding a tooltip, then?

Community
  • 1
  • 1
Orange Receptacle
  • 1,173
  • 3
  • 19
  • 40
  • 1
    Tooltips usually don't appear until you hold the mouse still for a moment or two: which doesn't seem to ever happen in your animated image. If it's really not working when you hover the mouse (instead of just moving it over the control), post a complete controller example. Aside: note for controls (like buttons) you can also do `button.setTooltip(...)`. – James_D Jun 05 '17 at 23:08
  • Is there a way of shortening the time it takes for it to allow it to show up? – Orange Receptacle Jun 05 '17 at 23:22

1 Answers1

1

Borrowing from one of a duplicate question's answer:

Button btn = new Button("Step");
btn.setTooltip(new Tooltip("This is a tooltip"));

This is a tooltip

As for the time it takes for the Tooltip to appear:

Typically, the tooltip is "activated" when the mouse moves over a Control. There is usually some delay between when the Tooltip becomes "activated" and when it is actually shown. The details (such as the amount of delay, etc) is left to the Skin implementation.

Taken from https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/Tooltip.html