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

CSS stylesheets do not style newly added nodes

    XMLWordPrintable

    Details

      Description

      Blocker: This is a regression in the 1.2 release (it was working previously in JavaFX 1.1). This defect was found in JavaFX 1.2 build 10.

      If you create a Scene and set a stylesheet, it immediately applies to all the nodes contained in that Scene. However, if you later add new nodes to the scene, those nodes do not get styled.

      A simple example to reproduce this follows (2 files):
      SkinningTest.fx:
      def rectBox:HBox = HBox {};
      Stage {
          scene: Scene {
              width: 200
              height: 20
              stylesheets: "{__DIR__}skin1.css"
              content: rectBox
          }
      }
      Timeline {
          keyFrames: for (i in [0..10]) KeyFrame {
              time: 1s * i
              action: function() {
                  insert Rectangle {
                      id: "surface"
                      width: 20
                      height: 20
                  } into rectBox.content;
              }
          }
      }.play();

      skin1.css:
      #surface {
        fill: red
      }

      This program adds in 10 rectangles, 1 per second. Due to the stylesheet set, the rectangles should have a red fill; however, they show up with the default fill color of black (a screenshot is attached).

      Files to reproduce this issue are attached.

        Attachments

        1. skin1.css
          0.0 kB
        2. skinningBug.png
          skinningBug.png
          2 kB
        3. SkinningTest.fx
          0.7 kB

          Issue Links

            Activity

              People

              Assignee:
              dgrieve David Grieve
              Reporter:
              schin Stephen Chin (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported: