StyleManager#reloadStylesheets(Scene) replacement in FX8

Tom Schindl tom.schindl at bestsolution.at
Wed Dec 5 16:38:04 PST 2012


Hi David,

Interesting I think my problem is very special because when ever I
reload my FXML-Preview I'm constructing a completely new scene and
simply set a new scene on the Stage (well in my case it is an FXCanvas
but that's not the real problem).

I reduced the problem to the following:

> public class MyCSSReloadTest extends Application {
> 
>     public static void main(String[] args) {
>         MyCSSReloadTest.launch(args);
>     }
>     
>     private Scene createScene(final Stage primaryStage) {
>         BorderPane p = new BorderPane();
>         final Scene s = new Scene(p,400,400);
>         final String stylesheet = MyCSSReloadTest.class.getResource("my.css").toExternalForm();
>         s.getStylesheets().add(stylesheet);
>         Button b = new Button("Reload "+  System.currentTimeMillis());
>         b.setOnAction(new EventHandler<ActionEvent>() {
> 
>             @Override
>             public void handle(ActionEvent event) {
>                 // s.getStylesheets().clear();
>                 primaryStage.setScene(createScene(primaryStage));
>             }
>         });
>         p.setCenter(b);
>         return s;
>     }
> 
>     @Override
>     public void start(Stage primaryStage) throws Exception {
>         primaryStage.setScene(createScene(primaryStage));
>         primaryStage.show();
>     }
> 
> }


if you uncomment thje s.getStylesheets().clear() the reloading works as
expected. I'm not sure now if this is expected behavior for performance
optimization you are not parsing the CSS when it is already on another
although soon to be GC'ed scene.

Tom

Am 05.12.12 14:47, schrieb David Grieve:
> Must be a bug. The code is intended to re-parse a stylesheet if it has been removed and re-added to the Scene (or Parent) stylesheets. 
> If you would create a bug, I will fix it ASAP.
> 
> On Dec 5, 2012, at 6:08 AM, Tom Schindl <tom.schindl at bestsolution.at> wrote:
> 
>> Hi David,
>>
>> I tested with the latest JRE8 and unfortunately this is not working. The
>> CSS is only reloaded from the filesystem when the JVM is restarted, so
>> the same caching as in 2.x is happening.
>>
>> Tom
>>
>> Am 03.12.12 18:13, schrieb David Grieve:
>>> Remove and re-add the stylesheet.
>>>
>>> On Dec 1, 2012, at 9:41 AM, Tom Schindl <tom.schindl at bestsolution.at> wrote:
>>>
>>>> Hi,
>>>>
>>>> To force reloading of stylesheets I used in FX2.2
>>>> StyleManager.getInstance().reloadStylesheets(scene). What is the
>>>> replacement of this in FX8.
>>>>
>>>> Tom
>>>>
>>>> -- 
>>>> B e s t S o l u t i o n . a t                        EDV Systemhaus GmbH
>>>> ------------------------------------------------------------------------
>>>> tom schindl                 geschäftsführer/CEO
>>>> ------------------------------------------------------------------------
>>>> eduard-bodem-gasse 5-7/1   A-6020 innsbruck     fax      ++43 512 935833
>>>> http://www.BestSolution.at                      phone    ++43 512 935834
>>>
>>
>>
>> -- 
>> B e s t S o l u t i o n . a t                        EDV Systemhaus GmbH
>> ------------------------------------------------------------------------
>> tom schindl                 geschäftsführer/CEO
>> ------------------------------------------------------------------------
>> eduard-bodem-gasse 5-7/1   A-6020 innsbruck     fax      ++43 512 935833
>> http://www.BestSolution.at                      phone    ++43 512 935834
> 


-- 
B e s t S o l u t i o n . a t                        EDV Systemhaus GmbH
------------------------------------------------------------------------
tom schindl                 geschäftsführer/CEO
------------------------------------------------------------------------
eduard-bodem-gasse 5-7/1   A-6020 innsbruck     fax      ++43 512 935833
http://www.BestSolution.at                      phone    ++43 512 935834


More information about the openjfx-dev mailing list