adding css file to stylesheets in javafx

前端 未结 18 1312
[愿得一人]
[愿得一人] 2020-12-06 05:27

Language: JavaFX

IDE: Netbeans

Problem: I\'m trying to add a css file to the stylesheet, but the first line of the following code always generates a Nu

18条回答
  •  隐瞒了意图╮
    2020-12-06 05:48

    I had the same problem (in NetBeans 8). I found a solution here : https://blog.idrsolutions.com/2014/04/use-external-css-files-javafx/

    My resource file spreadsheet.css was here :

    MyApp
    -resources
    --spreadsheet.css
    -source packages
    --fr.ccc.myapp.view
    ---mainView.java
    ---FXMLMain.fxml
    

    In mainView.java :

    File f = new File("resources/spreadsheet.css");
    spreadsheet.getStylesheets().add("file:///" + f.getAbsolutePath().replace("\\", "/"));
    

    Hope this helps.

提交回复
热议问题