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

Node.getStyleClass().add(clazz) does not work

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux

      Description

      FULL PRODUCT VERSION :
      eduarddrenth@eduarddrenth-TECRA-S11:~$ java -version
      java version "1.8.0_92"
      Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux eduarddrenth-TECRA-S11 3.13.0-88-generic #135-Ubuntu SMP Wed Jun 8 21:10:42 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      fxml:

               <TextFlow fx:id="datamappingxsd".....

      Controller#initialize:

               SaxParser parser = new SaxParser();
               XmlContentHandler handler = new XmlContentHandler();
               parser.parse(DatamappingHelper.class.getResourceAsStream(DatamappingHelper.XSD), handler);
               datamappingxsd.getChildren().addAll(handler.getTexts());

      XmlContentHandler:

            Text t = new Text("</" + qName + '>');
            t.getStyleClass().add("xmlelement");
            texts.add(t);

      Styles.css:

               .xmlelement {
                  -fx-text-fill: blue;
               }

      StylesheetBuilder#start(Stage):

            Scene scene = new Scene(root);
            String css = StylesheetBuilder.class.getResource("/styles/Styles.css").toExternalForm();
            scene.getStylesheets().add(css);


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      - create an fxml with a TextFlow in it with an fx:id
      - create a stylesheet with: .blue { -fx-text-fill: blue }
      - create a Controler with a TextFlow field, add a Text with a styleClass "blue" in the initialize method
      - create an application to run this

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      some blue text
      ACTUAL -
      some black text

      REPRODUCIBILITY :
      This bug can be reproduced always.

        Attachments

          Activity

            People

            • Assignee:
              jgiles Jonathan Giles
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: