Using the following code, I can assign a LinearGradient to the background of a ScrollView from the StyleSheet. But as soon as a Node is added to the ScrollView an exception is thrown. A solid color works fine.
Stage {
var sceneRef: Scene;
title: "ScrollView Background"
scene: sceneRef = Scene {
width: 400
height: 300
stylesheets: "{__DIR__}scrollViewBackground.css"
content: [
ScrollView {
width: bind sceneRef.width
height: bind sceneRef.height
node: Button {} // If this is commented out, everything is fine
}
]
}
}
Style sheet:
.scene {
-fx-background: linear (0%, 0%) to (0%, 100%) stops (0%, derive(skyblue, 25%)) (100%, derive(skyblue,-25%));
/* -fx-background: skyblue;*/
}
The exception is:
Unexpected exception caught in MasterTimer.timePulse():
java.lang.ClassCastException: javafx.scene.paint.LinearGradient cannot be cast to javafx.scene.paint.Color
at com.sun.stylesheet.css.Type$Type$Script$1Type$ObjLit$8.derive(Type.fx:111)
at com.sun.stylesheet.css.Type$PaintType.getParsedValue(Type.fx:646)
at com.sun.stylesheet.css.Type$PaintType.getParsedValue(Type.fx:644)
at com.sun.stylesheet.css.Type$PaintType.convert(Type.fx:635)
at com.sun.stylesheet.css.Type$PaintType.convert(Type.fx:629)
at com.sun.stylesheet.css.Type.convert(Type.fx:211)
at com.sun.stylesheet.StyleHelper.lookup(StyleHelper.fx:330)
at com.sun.stylesheet.StyleHelper.lookup(StyleHelper.fx:265)
at com.sun.stylesheet.StyleHelper.transitionToState(StyleHelper.fx:168)
at javafx.scene.Node.impl_processCSS(Node.fx:3107)
at javafx.scene.Parent.impl_processCSS(Parent.fx:872)
at javafx.scene.Parent.impl_processCSS(Parent.fx:875)
at javafx.scene.Parent.impl_processCSS(Parent.fx:875)
at javafx.scene.Parent.impl_processCSS(Parent.fx:875)
at javafx.scene.Parent.impl_processCSS(Parent.fx:875)
at javafx.scene.Parent.impl_processCSS(Parent.fx:875)
at javafx.scene.Parent.impl_processCSS(Parent.fx:875)
at javafx.scene.Scene.doCSSPass(Scene.fx:285)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.fx:924)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.fx:143)
at com.sun.javafx.tk.Toolkit.handleMasterTimerPulse(Toolkit.fx:132)
at com.sun.javafx.tk.Toolkit$1com$ObjLit$5.firePulseImpl(Toolkit.fx:304)
at com.sun.scenario.ToolkitAccessor.firePulse(ToolkitAccessor.java:55)
at com.sun.scenario.scenegraph.JSGPanelRepainter$FrameDisplay.run(JSGPanelRepainter.java:133)
at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(AbstractMasterTimer.java:420)
at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(AbstractMasterTimer.java:296)
at com.sun.embeddedswing.EmbeddedEventQueue.doPulse(EmbeddedEventQueue.java:570)
at com.sun.embeddedswing.EmbeddedEventQueue.access$000(EmbeddedEventQueue.java:82)
at com.sun.embeddedswing.EmbeddedEventQueue$2.run(EmbeddedEventQueue.java:473)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:633)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Stage {
var sceneRef: Scene;
title: "ScrollView Background"
scene: sceneRef = Scene {
width: 400
height: 300
stylesheets: "{__DIR__}scrollViewBackground.css"
content: [
ScrollView {
width: bind sceneRef.width
height: bind sceneRef.height
node: Button {} // If this is commented out, everything is fine
}
]
}
}
Style sheet:
.scene {
-fx-background: linear (0%, 0%) to (0%, 100%) stops (0%, derive(skyblue, 25%)) (100%, derive(skyblue,-25%));
/* -fx-background: skyblue;*/
}
The exception is:
Unexpected exception caught in MasterTimer.timePulse():
java.lang.ClassCastException: javafx.scene.paint.LinearGradient cannot be cast to javafx.scene.paint.Color
at com.sun.stylesheet.css.Type$Type$Script$1Type$ObjLit$8.derive(Type.fx:111)
at com.sun.stylesheet.css.Type$PaintType.getParsedValue(Type.fx:646)
at com.sun.stylesheet.css.Type$PaintType.getParsedValue(Type.fx:644)
at com.sun.stylesheet.css.Type$PaintType.convert(Type.fx:635)
at com.sun.stylesheet.css.Type$PaintType.convert(Type.fx:629)
at com.sun.stylesheet.css.Type.convert(Type.fx:211)
at com.sun.stylesheet.StyleHelper.lookup(StyleHelper.fx:330)
at com.sun.stylesheet.StyleHelper.lookup(StyleHelper.fx:265)
at com.sun.stylesheet.StyleHelper.transitionToState(StyleHelper.fx:168)
at javafx.scene.Node.impl_processCSS(Node.fx:3107)
at javafx.scene.Parent.impl_processCSS(Parent.fx:872)
at javafx.scene.Parent.impl_processCSS(Parent.fx:875)
at javafx.scene.Parent.impl_processCSS(Parent.fx:875)
at javafx.scene.Parent.impl_processCSS(Parent.fx:875)
at javafx.scene.Parent.impl_processCSS(Parent.fx:875)
at javafx.scene.Parent.impl_processCSS(Parent.fx:875)
at javafx.scene.Parent.impl_processCSS(Parent.fx:875)
at javafx.scene.Scene.doCSSPass(Scene.fx:285)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.fx:924)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.fx:143)
at com.sun.javafx.tk.Toolkit.handleMasterTimerPulse(Toolkit.fx:132)
at com.sun.javafx.tk.Toolkit$1com$ObjLit$5.firePulseImpl(Toolkit.fx:304)
at com.sun.scenario.ToolkitAccessor.firePulse(ToolkitAccessor.java:55)
at com.sun.scenario.scenegraph.JSGPanelRepainter$FrameDisplay.run(JSGPanelRepainter.java:133)
at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(AbstractMasterTimer.java:420)
at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(AbstractMasterTimer.java:296)
at com.sun.embeddedswing.EmbeddedEventQueue.doPulse(EmbeddedEventQueue.java:570)
at com.sun.embeddedswing.EmbeddedEventQueue.access$000(EmbeddedEventQueue.java:82)
at com.sun.embeddedswing.EmbeddedEventQueue$2.run(EmbeddedEventQueue.java:473)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:633)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)