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

Changing CSS Id at run-time on Tab does not result in changing style

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8u40, 9
    • javafx
    • None

      I need to set CSS Id on Tab at run-time, but ot seems like it doesn't work.
      I can set Id before stage is shown, but after that tab remains previous style.

      public void start(Stage primaryStage) throws Exception {
              TabPane tabPane = new TabPane();

              Tab first = new Tab("I'm red");
              first.setId("red");
              first.setClosable(false);

              Tab second = new Tab("I wanna be red");
              second.setClosable(false);
              Button button = new Button("Make it red");
              button.setOnAction( e-> {
                  second.setId("red");
                  button.setId("red");
              });
              second.setContent(button);

              tabPane.getTabs().addAll(first, second);

              Scene scene = new Scene(tabPane);
              scene.getStylesheets().add("Example.css");
              primaryStage.setScene(scene);
              primaryStage.show();
          }

      Example.css:
      #red {
          -fx-background-color: red;
      }

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

              Created:
              Updated:
              Imported: