Hi again.

So, you’re probably now thinking or saying, oh no, don’t tell me this is yet another library 😩

And you’re right, it is another library announcement! 🎉

Details

This is a library that contains classes to help in theme development. Right now, 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).

OK, so before you say I have some kind of library addiction, hear me out 🧐. At first, I thought I’d add this to FXComponents but then I thought that this type of functionality makes more sense on a “Theme library”. I could have added it to one of my theme repos but since I already have 2 themes in the making and might have more in the future, I think it makes sense for this to be a thing on itself.

If you want to get more details, check the documentation page. The code is available on Github.

Features

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.

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

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.

2 thoughts on “FXThemes Java/JavaFX library released

  1. wow nice! The dark mode frame color is something I was waiting for. I didn’t think it could be done via library due to its native code. Glad you found a way around it.

    • Thanks Saeid, I’m glad you like it!

      Yap indeed, it does require native code and JavaFX doesn’t make that easy 🙂

      Cheers!

Leave a Reply

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