How to use external CSS in a JavaFX application?

2

I'm doing an application with JavaFX and would like to put CSS in an external file, for example, the file would be located in the "C: \ app \ css" directory.

Is it possible to recognize the external file?

    
asked by anonymous 11.04.2016 / 21:46

1 answer

3

Use the instance of class Scene , example:

Scene cena = new Scene(Parent);
cena.getStylesheets().add(getClass().getResource("Caminho_Para_O_Arquivo"));

If this does not work, try this:

cena.getStylesheets().add(getClass().getResource("Caminho_Para_O_Arquivo").toExternalForm());
    
12.04.2016 / 00:19