Class CssLiveReload

java.lang.Object
ch.autumo.ui.utils.CssLiveReload

public final class CssLiveReload extends Object
Development-only live reload for style/application.css.

JavaFX caches parsed style sheets per URL, so re-adding the same URL has no effect. This watcher therefore writes every change to a newly named copy in a temp directory and swaps the scene's style sheet entry — JavaFX then parses the fresh URL and applies the rules immediately. No restart needed while tweaking padding, fonts or colours.

It only activates for a development run: the style sheet must be a file: URL below target/classes and the matching src/main/resources source file must exist. In a packaged application (JAR URL) it does nothing. It is off by default and has to be switched on explicitly with -Dapp.livereload=true on the command line (e.g. in the application's start script).

Java code still needs a rebuild and restart; this covers style changes only.

  • Method Details

    • install

      public static void install(Scene scene, String stylesheetUrl, String appId)
      Start watching the source file behind stylesheetUrl and keep the scene up to date.
      Parameters:
      scene - the live scene whose style sheet entry is swapped
      stylesheetUrl - the style/application.css URL that was added to the scene
      appId - app ID; one word, no spaces