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

CSS .myParent > .scroll-bar does not work for pane.getChildren().add(scrollBar)

XMLWordPrintable

      One would expect the scroll bar to be red. Change the child relationship to descendant and the selector matches.
      Knowing that the skin is a child of the ScrollBar, .myParent > * > .scroll-bar should work but does not.

      /*
       * demo.css
       */
      .myParent > .scroll-bar {
          -fx-border-color: red;
      }

      package javaapplication37;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.ScrollBar;
      import javafx.scene.layout.AnchorPane;
      import javafx.stage.Stage;

      /**
       *
       * @author jfdenise
       */
      public class JavaApplication37 extends Application {

          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              Application.launch(args);
          }

          @Override
          public void start(Stage primaryStage) throws Exception {
              AnchorPane ap = new AnchorPane();
              ap.getStyleClass().add("myParent");
              ScrollBar sb = new ScrollBar();
              ap.getChildren().add(sb);
              
              Scene scene = new Scene(ap, 100, 100);
              scene.getStylesheets().add(JavaApplication37.class.getResource("demo.css").toExternalForm());

              primaryStage.setScene(scene);
              primaryStage.setVisible(true);
          }
      }

            dgrieve David Grieve
            dgrieve David Grieve
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: