adding css file to stylesheets in javafx

前端 未结 18 1346
[愿得一人]
[愿得一人] 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 06:02

    Assuming the file structure is something like this:
    -root
    --src
    ---resources
    ----double_slider.css
    ---package
    ----JavaFXFile.java

    This is what worked for me:

    scene.getStylesheets().add((new File("src/resources/double_slider.css")).toURI().toString());
    

提交回复
热议问题