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

Pane css style refresh do that contained elements reset their styles.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • 8
    • javafx
    • Windows7 64bits and Linux 64bits with Java8 beta79

      When you define, with css styles, a pane that contains other elemente and that elements are defined with css styles too, if you modify the border style of the pane, all of the contained elements reset they style while the refresh style it is applying.

      Example code:

      @Override
      public void start(Stage primaryStage) throws FocucsException{

      Group root=new Group();

      Scene scene = new Scene(root,1000,800);
      scene.setFill(Color.BLACK);
      scene.getStylesheets().add(getClass().getResource("paneBorderTest.css").toExternalForm());

      mainPane.setId("mainPane");
      mainPane.setPrefHeight(200);
      mainPane.setPrefWidth(200);
      mainPane.setLayoutX(400);
      mainPane.setLayoutY(400);

      Label label=new Label("Test");
      label.setId("mainLabel");
      label.setLayoutX(5);
      label.setLayoutY(5);
      label.setPrefHeight(100);
      label.setPrefWidth(160);
      mainPane.getChildren().add(label);


      root.getChildren().add(mainPane);

      primaryStage.setScene(scene);
      primaryStage.show();


      scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
      public void handle(KeyEvent ke) {
      String keyPressed=ke.getText() ;
      logger.info("Key typed: "+keyPressed);
      if("s".equals(keyPressed)){
      mainPane.setStyle("-fx-border-width:2px 2px 0px 2px;");
      }
      else if("a".equals(keyPressed)){
      mainPane.setStyle("-fx-border-width:2px 2px 2px 2px;");
      }
      }
      });
      }

      And css code:

      #mainPane
      {
      -fx-background-color: red;
      -fx-border-color:white;
      -fx-border-width:3px 3px 3px 3px;
      }

      #mainLabel{
      -fx-text-fill:#FFFFFF;
      -fx-font-family:Arial;
      -fx-font-size:12px;
      }

            dgrieve David Grieve
            alopezjfx Antonio Lopez (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: