Hello fellow devs,

Another release of the FXThemes library. This release brings with it Mac support for some of the already existing features.

With the necessary infrastructure in place this release also makes it easier for future implementations targeted for the Mac OS to be easily integrated into FXThemes.

FXThemes version 1.5 details

First of all, I’d like to say that I’m very glad that Carl Dea (@carldea) has joined the effort to develop the FXThemes library.

I’m sure a lot of you already know Carl. Carl is a Java and JavaFX guru. I’ve been using JavaFX since the very start, even when it was still on beta and I remember that back then Carl was also one of the first developers to start using and posting articles about it. AFAIK he was the author of one of the first books on JavaFX.

He is working on the Mac support of FXThemes.

New features

As alluded to in the introduction this release brings a new feature: dark/light mode support on Mac and new infrastructure to make features aimed towards Mac be more easily and rapidly integrated.

Dark / Light mode support

The following video in a tweet I’ve made, illustrates “true dark mode” support for Windows in action. I called it “true” because now the developer will also be able to change the window frame to match the dark or light appearance (it can look a bit off if the frame is in a different appearance).

This is now also available for Mac, thanks to Carl!

With this release you can call the following code on either Mac or Windows to set the title bar of a window to a dark appearance:

ThemeWindowManager themeWindowManager = ThemeWindowManagerFactory.create();
themeWindowManager.setDarkModeForWindowFrame(primaryStage, true);

This will work irrespective of the OS the user is running your app in. In the code above primaryStage is the stage whose window title bar you want to change. If you pass in true it will change to dark, if you pass in false it will change to light appearance.

The call ThemeWindowManagerFactory.create() will return the appropriate instance implementation of ThemeWindowManager (Mac implementation for Mac, Windows implementation for Windows, etc).

If you want to see a complete example check the DarkThemeSample Sample.

Build Infrastructure

The build and deployment that happens automatically on the FXThemes repository is handled through github actions that run on a Mac M1 computer. For now only one jar is built and deployed on Maven Central. That library jar will work on both Windows and Mac. The Windows part doesn’t need any extra native code since, through the use of JNA, it calls upon native libraries that will already exist in the user machine. For the Mac part we build some extra Objective-C code on XCode and put it inside the jar. This code will then be called through Java.

This infrastructure that is already in place will allow the addiction of features, either targeted for Mac or for Windows, in an easier and quicker way.

Future developments

We have a bunch of features we’re going to like to add in the future.

For instance, we already have background blur of a window working on Mac (FXThemes already allows you to do that on Windows) we just need to integrate it into a new release of FXThemes and also think of some platform agnostic API that will expose the minimal common denominator between platforms. Irrespective of this we’ll also provide API to allow the developer to call upon features that are only available on each specific platform.

As always, check the FXThemes documentation if you want to know more about this library.

One thought on “FXThemes version 1.5 released

Leave a Reply

Your email address will not be published. Required fields are marked *