Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.setDisable(true);
txt.searchText.setTooltip(new Tooltip("Message"));

Has anyone a solution for that problem?

Thx

like image 874
Flagman Avatar asked Jun 10 '14 12:06

Flagman


1 Answers

Not directly but you can warp your button into another control and while your button could be disable or not, the control will answer to mouse movements.

Button button = new Button("Click me");     //create a button
button.setDisable(true);        //disable button in some way
SplitPane splitPane = new SplitPane(button);   //warp it into a splitPane
splitPane.setTooltip(new Tooltip("I'm the Tooltip Massage")); //Crete a tooltip

Node that SplitPane extends "Controls" not Region and not pane.

so it's a Control and best for our case (warping buttons).

you must always use a Control to warp another control. other way you will not have access to setTooltip() method.

like image 93
ARiyou Jahan Avatar answered Sep 19 '22 08:09

ARiyou Jahan