Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8088832

'Resource "<file>.css" not found' Error if using FXMLLoader.load(java.io.InputStream inputStream) method

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8u25
    • javafx
    • None

      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);
          ...

            Unassigned Unassigned
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Imported: