Currently JavaFX does not allow attaching a stylesheet to a node (or scene) that is not in the classpath. So, if a css file is not in the classpath already, it cannot be added to any node. The getStyleSheets().add() method will state 'WARNING Resource [your file] not found'. So is there any workaround to this limitation?
Not sure if this is what you are looking for...
Button node = new Button();
node.getStyleClass().add("my-new-style-class");
.my-new-style-class {
-fx-padding: 5;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With