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

[CSS] Unable to get an effective import with a CSS file containing @import statements

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • 8u40
    • 8u40
    • javafx
    • Java 8 U40 b02

      The code below doesn't allow to get Modena yellow-on-black look (you get no styling at all).
      I call setUserAgentStylesheet on a SubScene and provide a CSS file that imports two other CSS files which are all stored in the same folder on disk.

      modena.css and yellowOnBlack.css are directly copied from the FX rt repository.

      The issue isn't linked to the use of a SubScene: doing the same setUserAgentStylesheet call directly on the Scene gives the same user experience.

      Attached zip is the full NetBeans project.

      public class CSSImport extends Application {

          public static void main(String[] args) {
              Application.launch(args);
          }

          @Override public void start(Stage stage) {
              stage.setTitle("CSSImport : SubScene case");
              Scene scene = new Scene(new Group(), 600, 450);
              scene.setFill(Color.LIGHTGREEN);

              VBox subSceneRoot = new VBox(5, new Label("Modena yellowOnBlack style button in a SubScene"), new Button("YELLOW-ON-BLACK"));
              subSceneRoot.setStyle("-fx-border-color: white; -fx-alignment: center;");
              SubScene mySubScene = new SubScene(subSceneRoot, 450, 100);
              // Line below gives Modena look, just fine !
      // mySubScene.setUserAgentStylesheet("cssimport/modena.css");
              // Line below doesn't give the expected yellow-on-black Modena
      mySubScene.setUserAgentStylesheet("cssimport/modena-highContrast-yellowOnBlack.css");

              mySubScene.setLayoutX(25);
              mySubScene.setLayoutY(210);

              ((Group)scene.getRoot()).getChildren().addAll(mySubScene);
              stage.setScene(scene);
              stage.show();
          }
      }

      /* modena-highContrast-yellowOnBlack */
      @import “modena.css";
      @import “yellowOnBlack.css”;

            dgrieve David Grieve
            yjoan Yves Joan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: