JavaFX 2: How to load stylesheet into a Scene subclass distributed as part of a library?

后端 未结 2 939
眼角桃花
眼角桃花 2021-01-14 07:19

I\'m subclassing many of the JavaFX 2 classes to distribute them as part of a library that will be used by others. This requires that a stylesheet (part of the library) be a

相关标签:
2条回答
  • 2021-01-14 07:44

    Finally tracked down the problem to Intellij IDEA CE which, by default, does not recognize css files as a resource that needs to be copied from the source to the target dir. Adding a *.css pattern to list of recognized resource types fixed the problem.

    0 讨论(0)
  • 2021-01-14 07:50

    I've only had luck with this syntax as found in the Ensemble sample:

    scene.getStylesheets().addAll(Ensemble2.class.getResource("ensemble2.css").toExternalForm());
    
    0 讨论(0)
提交回复
热议问题