Using code from this tutorial:
http://code.makery.ch/java/javafx-8-tutorial-part4/
If you have FXML file with 'stylesheets' attribute set in root pane:
<AnchorPane prefHeight="363.0" prefWidth="693.0" stylesheets="@DarkTheme.css" ...
Then you load the FXML with this code:
FXMLLoader loader = new FXMLLoader();
AnchorPane personOverview = (AnchorPane)loader.load(getClass().getResource("view/PersonOverview.fxml").openStream());
this.rootLayout.setCenter(personOverview);
...
You would get error message in eclipse output screen like this:
null/DarkTheme.css
Dec 09, 2014 1:42:54 AM com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged
WARNING: Resource "DarkTheme.css" not found.
But there will be no error if you do it like this:
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainApp.class.getResource("view/PersonOverview.fxml"));
AnchorPane personOverview = (AnchorPane) loader.load();
this.rootLayout.setCenter(personOverview);
...
and if you use static method FXMLLoader.load(java.net.URL location):
AnchorPane personOverview = FXMLLoader.load(getClass().getResource("view/PersonOverview.fxml"));
this.rootLayout.setCenter(personOverview);
...
http://code.makery.ch/java/javafx-8-tutorial-part4/
If you have FXML file with 'stylesheets' attribute set in root pane:
<AnchorPane prefHeight="363.0" prefWidth="693.0" stylesheets="@DarkTheme.css" ...
Then you load the FXML with this code:
FXMLLoader loader = new FXMLLoader();
AnchorPane personOverview = (AnchorPane)loader.load(getClass().getResource("view/PersonOverview.fxml").openStream());
this.rootLayout.setCenter(personOverview);
...
You would get error message in eclipse output screen like this:
null/DarkTheme.css
Dec 09, 2014 1:42:54 AM com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged
WARNING: Resource "DarkTheme.css" not found.
But there will be no error if you do it like this:
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainApp.class.getResource("view/PersonOverview.fxml"));
AnchorPane personOverview = (AnchorPane) loader.load();
this.rootLayout.setCenter(personOverview);
...
and if you use static method FXMLLoader.load(java.net.URL location):
AnchorPane personOverview = FXMLLoader.load(getClass().getResource("view/PersonOverview.fxml"));
this.rootLayout.setCenter(personOverview);
...