Javafx CSS values in code

573 views Asked by At

Simply put, I have a JavaFX Textfield that I wish to 1) change the text color on, and 2) change it back to that specified in CSS. Does anyone know how to (generally) access css colors etc. from within the JavaFX code?

2

There are 2 answers

0
user3224416 On
AnyFxElement.setStyle(String elementCss);

For source of all the css capabilities I reccomend looking up caspian css.

0
AudioBubble On

To remove a style use the code:

    // remove the background color on the button
    yourElement.setStyle(null);

To set it back to it's default style:

    // set the button style back to the default class
    yourElement.setStyle(".yourStyle");