Handling updates to the JavaFX Caspian look

Tom Schindl tom.schindl at bestsolution.at
Mon Apr 23 16:12:02 PDT 2012


Am 24.04.12 00:56, schrieb Jonathan Giles:
> Tom,
> 
> Thanks for your feedback. I will therefore not modify the ServiceLoader
> code to be more OSGi friendly, and will instead direct people to
> e(fx)clipse and / or the Themes API to manually register their themes.
> 
> The API on Application was originally called
> setDefaultUserAgentStylesheet, but a more recent patch included in the
> Jira issue has renamed that to setTheme.
> 
> Regarding passing Theme or ThemeName to Application.setTheme().....I'm
> not sure. Using the Theme class forces the developer to become familiar
> with the Theme and Themes classes, which isn't a bad thing. I can also
> appreciate the verbosity of this approach. One compromise is to add a
> convenience method along the following lines to Application:
> 

My take on this is that the theme is most like passed as a String into
the system and so people will write code like this all the time:

String themeName = ....;

Theme t = Themes.getInstance().getTheme(themeName);
if( t == null ) {
   t = Themes.getInstance().getTheme(Themes.DEFAULT_THEME);
}

app.setTheme(t);


> public final void setTheme(String themeName) {
>     setTheme(Themes.getInstance().getTheme(themeName));
> }
> 

If you want to stick with the setTheme(Theme) yes.

My reason for the String API is that I'd give a theme more information
in future e.g. for which OS, OS-Version, OS-Theme is it good for and one
can have multiple themes with the same name but different
OS/OS-Version/OS-Theme.

So the registry would could look like this:
* MyAppTheme
  - os: linux
* MyAppTheme
  - os: win32
  - style: classic
* MyAppTheme
  - os: win32
  - style: xp
* MyAppTheme
  - os: mac

One can now call setTheme("MyAppTheme") and the framework will find the
correct theme depending on the OS, ... . For some of those things
there's most likely not even public API (e.g. because it is not
crossplatform) I could call but the framework probably can.

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


More information about the openjfx-dev mailing list