[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.5.1' 

Maven example:

 
<dependency>
    <groupId>com.pixelduke</groupId>
    <artifactId>fxthemes</artifactId>
    <version>1.5.1</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.

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 when on Windows. This flag might degrade performance (or might not). In the tests I’ve made no noticeable performance degradation was visible, however they were very simple.

Check the samples sub-project Maven 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”.

As FXThemes relies on calling native code on each platform it’s running in, each feature has to be individually coded for each OS. At the moment of writing the following OSes are supported:

  • Windows 11: supports all features;
  • Windows 10: currently only supports some of the features (“True dark mode” is supported);
  • Mac OS: supports some of the features but will soon support many more.

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.

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.

Change corners of a Window

  • Rectangle
  • Round
  • Less round

More information here: FXThemes version 1.6 released post

Set native window decorations on Stages

You can set native window decorations on TRANSPARENT or UNDECORATED Stages.

More information here: FXThemes version 1.6 released post