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.
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.
- duplicates
-
JDK-8107252 CSS styles are not applied to nodes added to the scene graph after initialization.
- Resolved