Reloading stylesheets

Werner Lehmann lehmann at media-interactive.de
Tue Dec 10 07:10:49 PST 2013


Got it. The key was to move the stylesheets from the root node to the 
scene before reloading them:

scene.styleSheets.clear
scene.styleSheets.addAll(root.styleSheets)
root.styleSheets.clear
styleManager.reload(scene)

The hotkey also works now: shift+ctrl+7 reloads CSS while the scene is 
visible. This works by using a custom scene, overriding 
impl_processKeyEvent. Even better would be automatic change-detection 
(in debug mode only) but I don't have time to do this now. Previously 
you said that reloading is not needed on FX8... does this work out of 
the box then?

Werner

On 10.12.2013 14:10, Tom Schindl wrote:
> My code does:
>
>> // Force CSS-Reloading
>> if( isJavaFX2() ) {
>>    ReflectiveInvoke.onStyleManagerClass(scene);
>> }
>>
>> scene.getStylesheets().clear();	
>> scene.getStylesheets().addAll(contentData.cssFiles);
>
> A difference I see is that your stylesheets are on the Root-Container
> whereas mine are directly on the Scene.
>
> Tom


More information about the openjfx-dev mailing list