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

[CSS, PopupControl] WARNING: javafx.scene.CssStyleHelper calculateValue. Could not resolve...

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8u20
    • Component/s: javafx
    • Labels:
      None
    • Environment:

      Mac OSX Mavericks 10.9.2
      JDK: 1.8.0-b132
      JavaFx: 8.0.0-b132

      Description

      Creating a PopupControl with a child that overrides getUserAgentStylesheet generates some warnings:

      Mar 19, 2014 2:27:21 PM javafx.scene.CssStyleHelper calculateValue
      WARNING: Could not resolve '-fx-text-background-color' while resolving lookups for '-fx-text-fill' from rule '*.label' in stylesheet jar:file:/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
      Mar 19, 2014 2:27:21 PM javafx.scene.CssStyleHelper calculateValue
      WARNING: Could not resolve '-fx-text-background-color' while resolving lookups for '-fx-text-fill' from rule '*.label' in stylesheet jar:file:/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
      Mar 19, 2014 2:27:21 PM javafx.scene.CssStyleHelper calculateValue
      WARNING: Could not resolve '-fx-text-background-color' while resolving lookups for '-fx-text-fill' from rule '*.label' in stylesheet jar:file:/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss
      Mar 19, 2014 2:27:21 PM javafx.scene.CssStyleHelper calculateValue
      WARNING: Could not resolve '-fx-text-background-color' while resolving lookups for '-fx-text-fill' from rule '*.label' in stylesheet jar:file:/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/jre/lib/ext/jfxrt.jar!/com/sun/javafx/scene/control/skin/modena/modena.bss

      But instead of overriding getUserAgentStylesheet, simply loading the css file in the constructor works fine (see sample demo below)

      [Demo.java]
      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.scene.Node;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Control;
      import javafx.scene.control.Label;
      import javafx.scene.control.PopupControl;
      import javafx.scene.control.Skin;
      import javafx.scene.layout.Pane;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class Demo extends Application {
          class MyCustomControl extends Control {
              class MyCustomControlSkin implements Skin<MyCustomControl> {
                  private final MyCustomControl customControl;
                  private final Pane node;
                  public MyCustomControlSkin(final MyCustomControl control) {
                      this.customControl = control;
                      this.node = new Pane(new Label("Custom control"));
                      //getStylesheets().add(MyCustomControl.class.getResource("mycustomcontrol.css").toExternalForm());
                  }
                  @Override public MyCustomControl getSkinnable() {
                      return customControl;
                  }
                  @Override public Node getNode() {
                      return node;
                  }
                  @Override public void dispose() {}
              }
              
              public MyCustomControl() {
                  getStyleClass().add("my-custom-control");
              }
              @Override protected Skin<?> createDefaultSkin() {
                  return new MyCustomControlSkin(this);
              }
              @Override public String getUserAgentStylesheet() {
                  return MyCustomControl.class.getResource("mycustomcontrol.css").toExternalForm();
              }
          }
          
          class MyPopupControlSkin implements Skin<PopupControl> {
              private final PopupControl popupControl;
              private final Pane node;
              public MyPopupControlSkin(final PopupControl control) {
                  this.popupControl = control;
                  this.node = new VBox(new Label("Popup control"), new MyCustomControl());
              }
              @Override public PopupControl getSkinnable() {
                  return popupControl;
              }
              @Override public Node getNode() {
                  return node;
              }
              @Override public void dispose() {}
          }
          
          @Override public void start(Stage primaryStage) {
              Button btn = new Button("Open popup");
              btn.setOnAction((ActionEvent e) -> {
                  PopupControl popup = new PopupControl();
                  popup.setSkin(new MyPopupControlSkin(popup));
                  popup.show(btn, primaryStage.getX() + 160, primaryStage.getY() + 30);
              });
              primaryStage.setScene(new Scene(btn, 150, 50));
              primaryStage.show();
          }

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

      [mycustomcontrol.css]
      .my-custom-control {
          -fx-background-color: yellow;
      }

        Attachments

          Activity

            People

            Assignee:
            dgrieve David Grieve
            Reporter:
            badisijfx Badisi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: