Reputation: 23515
My FXML file has an attribute stylesheets="styles/Styles.css"
specified on the root node. This works fine when the program is launched. However, in Scene Builder 2 the css doesn't load, the console prints WARNING: Resource "styles/Styles.css" not found.
, the Properties panel doesn't work, and the console further prints stack traces. If the stylesheets attribute is specified with an absolute file:
url, then SB works, but I need the url to point to the classpath.
Upvotes: 2
Views: 966
Reputation: 510
In my case is stylesheet defined like this inside of root element:
<stylesheets>
<URL value="@css/base.css" />
</stylesheets>
In this notation it probable means, that file is searched for relatively from FXML file position.
But you must specify location of loaded FXML file in runtime.
// file = String with FXML file path, loader = FXMLLoader
URL resource = getClass().getResource(file);
loader.setLocation(resource);
I hope, it will help you...
Btw Scene Builder 2.0 is still Early Access version, so there might be some problem too...
Upvotes: 1