getStylesheets().add("css_file") has no effect for Scene in JFXPanel
I'm using Netbeans 7 to build a JavaFx application that has a Swing UI with a JFXPanel. No matter what I try, I can't get the scene to use my stylesheet.
The content of my CSS file is correct. E.g.:
.my-component {
-fx-border-color: black;
-fx-border-width: 2;
-fx-border-radius: 10;
-fx-background-color: #CCFF99;
-fx-background-radius: 10;
}
The path to the CSS file is correct. (e.g. "/packagename/mystyle.css"), I've also tried:
String css = Main.class.getResource("mystyle.css").toExternalForm();
scene.getStylesheets().add(css);
My node (a BorderPane) is set to use the CSS class :
comp2.getStyleClass().add("my-component");
I've verified the syntax by changing it to one of the built-in classes e.g. "button" and the results are seen in the UI.
But I can't get anything from my CSS file to work. There are no error messages logged or exceptions thrown. I can fill the CSS file with nonsense errors and it has no effect.. it's like the file isn't being used at all.
When I use the SAME CSS file in a pure JavaFX application, that is, NOT using JFXPanel, I see a warning if the path to the CSS file is wrong: "WARNING: com.sun.javafx.css.StyleManager$2 run Resource "null" not found."
When the path is correct in that case, it seems to work fine.
What could be the problem?