JavaFX 2.0 CSS Reference

All JavaFX 2 components can be styled with CSS 3. The CSS JavaFX 2 reference is available here: To activate your custom CSS you only have to add a resource containing the CSS styles to the javafx.scene.Scene:

        Scene scene = ...


Careful, this may not work if your net your NetBeans project properties to "Binary Encode JavaFX CSS Files" (in Project Properties->Build->Packaging).
If this is the case you'll have to look for the file "javafxrocks.bss" instead (".css" => ".bss").

You may want to modify your code to check if URL returned when seeking "javafxrocks.css" is null and if it's the case then search for "javafxrocks.bss" instead. This way it should work in both settings.

Posted by Fabrice Bouyé on January 16, 2012 at 01:34 AM CET #

I have found that this whole .css problem can be solved, when using NetBeans, go to the project properties - run - Standalone Application Properties - Working directory and select the path to the directory where the .css file and/or main class is located. I don't know what (windows) is using as default, probably a temp dir.. if so, then there are ofcourse no .css files there and you get the nullpointer exception. I haven't tried this mayself yet, but if you change the path in the .java file to: "temp/javafxrocks.css", it might work also.

Posted by André on April 19, 2012 at 01:54 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments