[Warning: this documentation might be slightly out-of-date. Check the code repository, check the samples sub-project. New controls and features might already have been added that are not present in this documentation page]

This is a library that contains classes to help in advanced theme development.

For example, it contains helper classes to change the appearance of a native window frame as well as the backdrop of JavaFX native Windows (the type of transparency effect on Windows).

The code is available on Github.

How to get it

This library is available on Maven Central.

Gradle example:

 implementation 'com.pixelduke:FXThemes:1.0.0' 

Maven example:

 
<dependency>
    <groupId>com.pixelduke</groupId>
    <artifactId>FXThemes</artifactId>
    <version>1.0.0</version>
</dependency>

Replace version number with the one you’d want.

Running the sample demos

To run the demos, enter the following command in the Command Prompt / Terminal, inside the project directory:

mvn javafx:run -f fxthemes-samples/pom.xml

To choose which demo to run, change the “pom.xml” script file inside “FXThemes-samples” folder and replace the contents of the <mainClass> xml tag with the name of the Application derived class you’d like to execute.

License

FXThemes license is “GNU General Public License, version 2, with the Classpath Exception’“

Request for feedback

If you’re using FXThemes please send pictures of your app to .

If you can, ideally, please also share it through social media (Twitter) and let me know (you can reference me through my twitter handle @P_Duke and you can also use the #FXThemes tag). It will be very important to check how you are using FXThemes and adjust it to better fit the use cases. Also, for showcasing example uses (if you allow).

It is also important for me, and to keep me motivated to continue, to know that FXThemes is being used and how it is being used.

Given all these unpaid work is given out for free, I just ask you to share it is being used and how if you can. 

Contributing

Contributions via Pull Requests (PR) are welcome! Help grow this library if you like it! Before filing a PR please create an issue in the issue tracker.

I’d be very happy if anyone wants to join in on the effort and help make this also available for other OSes. AS UIs continue to evolve, I believe this kind of API can bring an extra necessary shine to JavaFX applications.

My Mac is too old and has now become obsolete, so I don’t have a way to program this feature and make it available on a Mac. I also am only using Windows now, on my machine. Obviously full credit will be given to anyone that wants to join.

API

True Dark/Light mode

JavaFX native Windows always show with a light colored frame. This API allows the developer to change the frame color of a JavaFX native window to either a dark or light theme.

Change Window frame color, text color and border

API to change the Window frame color, text color and border is also present.

Change backdrop of Window

A backdrop of a Window is the “type” of transparency on the background of the Window. For Windows 11 there are 4 possible types of backdrop:

  • None: No backdrop. That is, no transparency effect whatsoever.
  • Acrylic: Transparent blurred background Window that simulates an acrylic material. The user will see through to anything that’s below (any Window, desktop background, etc). This is the least performant of all backdrops.
  • Mica: Samples the background of the user’s Desktop once (only the user’s desktop background) and adds transparency according to that. The user won’t see through any other Window that’s below, he’ll only see through the desktop background. This is a more performant alternative than “Acrylic”.
  • Mica Alt: A variation of Mica that’s less subtle.

A few considerations

All this API requires the developer using the library to forcefully “open” and “export” some private packages in the JavaFX SDK, namely this is required for the library to be able to get the native Window Handle.

To change the backdrop an additional change needs to be made. The flag “prism.forceUploadingPainter=true” needs to be set before running the app. This flag will likely degrade performance. The tests I’ve made were very simple, so no noticeable performance degradation was visible. I’d say using backdrop API, for now, might not be ideal where performance is critical.

Check the samples sub-project Gradle build script for an example of how to open/export private packages of JavaFX and how to add the necessary flag to use the “backdrop API”.

At the moment of writing, only the Windows 11 operating system is supported as this relies on calling native code through the Win32 API.