Show Tooltip on disabled Control in JavaFX


It is possible to show a Tooltip on a disabled Control?

I have the following code and this doesn't work:

txt.searchText.setTooltip(new Tooltip("Message"));

Has anyone a solution for that problem?


6/10/2014 12:47:59 PM

Accepted Answer

The answer is no. Currently you cannot show a tooltip on disabled Node, for the simple reason that disabled Nodes do not receive any MouseEvents.

You can see the issue being raised in the official issue tracler here (require login) :

One solution to your problem could be to wrap your Control into something else.

For example, put your control into another Control, like a SplitPane or a Label. Then you could apply your tooltip to that wrapper and disable your first control.

7/18/2014 2:23:27 PM

Here's a workaround using the CustomMenuItem class:

    customMenuItem.getContent().setOnMouseEntered(e -> {
        if (customMenuItem.isDisable()) {
            Tooltip.install(customMenuItem.getContent(), tooltip);
        } else {
            Tooltip.uninstall(customMenuItem.getContent(), tooltip);

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow