Forum Discussion

exdunepilot's avatar
exdunepilot
Contributor
7 years ago

Finding the Text Color in a JavaFX Tooltip & CSS

Normally we can find the text colors in our JavaFX objects using methods such as getBackground(), getForeground, getEffect(), getStyle(), getFill() etc.  But the Tooltip JavaFX object is different and we cannot get to any color value (and it really doesn't matter the type of value such as RGB, hex, etc.  any color value would do!). 

 

We set the tooltip in CSS using the typical "fx-text-fill: black."   I believe part of the problem is that Tooltip.getText() returns a text string versus a Text object.

 

Any suggestions?

 

TIA.

3 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    A string is still a value that you can test against.  Do you get the string "black" in this case?

    • exdunepilot's avatar
      exdunepilot
      Contributor

      Hi Marsha,

       

      Thanks for the reply.  We get the text "value" no problem or in other words, the content of the Tooltip which is of String type.  However, we need to find the color of the text, black, white, red, blue, green etc. and that is not readily available.  Generally with JavaFX these "colors" are returned in hex.  We first found the problem when the Tooltip's default background was a tan color and the text was white.  This made the content of the Tooltip essentially invisible to a user.