Reloading stylesheets
Tom Schindl
tom.schindl at bestsolution.at
Tue Dec 10 04:30:56 PST 2013
There is internal API:
com.sun.javafx.css.StyleManager.getInstance().reloadStylesheets(scene);
which is GONE in FX8 (but there it is not needed anyways) if you want to
support both platforms you need to use reflection to call it.
In e(fx)clipse preview I do:
> if( isJavaFX2() ) {
> ReflectiveInvoke.onStyleManagerClass(scene);
> }
where the reflective vode looks like:
> public static void onStyleManagerClass(Scene s) throws Exception {
> /*
> * com.sun.javafx.css.StyleManager.getInstance().reloadStylesheets(scene);
> */
> Class<?> cl = Class.forName("com.sun.javafx.css.StyleManager");
> Method m1 = cl.getMethod("getInstance");
> Object o1 = m1.invoke(null);
>
> Method m2 = cl.getMethod("reloadStylesheets", Scene.class);
> m2.invoke(o1, s);
> }
Tom
On 10.12.13 13:21, Werner Lehmann wrote:
> Hi,
>
> is there a way to reload previously loaded stylesheets (in FX2)?
>
> Currently I have to restart the application each time I am changing the
> css. It would be nice to just close and reopen that window instead to
> see the new styles. I'd like to unload css automatically when closing a
> window - in debug mode - in order to avoid the application restart.
>
> Or, even better, define a hotkey to update css immediately. Much like
> shift+ctrl+8 for ScenicView (only works in FX2 as far as I know).
>
> Rgds
> Werner
More information about the openjfx-dev
mailing list