How to use external CSS in a Javafx application?

Asked

Viewed 436 times

2

I’m making an application with Javafx and would like to put the CSS in external file, for example, the file would be located in the directory "C: app css".

It is possible to recognize the external file?

1 answer

3

Use the class instance Scene, example:

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

If it doesn’t work out, try it this way:

cena.getStylesheets().add(getClass().getResource("Caminho_Para_O_Arquivo").toExternalForm());

Browser other questions tagged

You are not signed in. Login or sign up in order to post.