Aleksandr Dubinsky
Aleksandr Dubinsky

Reputation: 23515

Scene Builder 2.0 can't load stylesheet from resources/classpath

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

Answers (1)

none_
none_

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

Related Questions