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

Add official support to refresh or reload CSS files that have been modified externally

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • fx2.1
    • fx2.0
    • javafx

      Scene.getStylesheets() takes a list of URLs, so instead of using a resource file on the classpath I can use "file:///somepath". This works as expected. Now I'd like to change that file on the filesystem and then re-apply it to the scene to view my changes without the need to restart my application.

      I tried to execute:

      scene.getStylesheets().clear();
      scene.getStylesheets().add("file:///somepath/stylesheet.css");

      after I've changed the file /somepath/stylesheet.css on the filesystem but there is no change to the applied styles at all.

      According to

        https://forums.oracle.com/forums/thread.jspa?forumID=1385&threadID=2294345

      this is possible using a private API:

        com.sun.javafx.css.StyleManager.getInstance().reloadStylesheets(scene);

      but adding official support for this (or a similar mechanism maybe even automatically) would probably be better.

            dgrieve David Grieve
            jhohmuthjfx Jens Hohmuth (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: