FlatLaf
FlatLaf copied to clipboard
FlatLight is not that light
When I look at a web page (like this very page for the bug report), we can see that the colors are very light. Backgrounds are white for example. I checked all the themes that are part of the demo and there is none that is this light.
The default light theme is almost right, but it is using a gray background for panels. I tried this naive approach:
defaults.put("Panel.background", Color.WHITE);
defaults.put("TabbedPane.background", Color.WHITE);
... but I probably need a few other keys, because some elements still have a gray background in their passive form (e.g. tool bar buttons).
Basically, instead of this:
I was hoping for something more like this (done with Photoshop, I did not thoroughly proof read!):
Do you have plan to make a truly light (more web-like) theme? What are the keys I need to set or the easiest path to getting the result I hope for?
For such global changes it is best to use a .properties file and benefit from the power of variables, functions, etc that FlatLaf uses to build UI defaults.
You can use FlatLaf Demo to test own .properties files. Simply create a properties file in the working directory of the Demo app (usually the same directory as the demo JAR). The Demo scans the working directory on window activation and shows found properties files in the Themes list (category "Current directory"). Also changes made to the properties files are automatically loaded on window activation.
You can use DemoLaf.properties
as base:
https://github.com/JFormDesigner/FlatLaf/blob/14c837ad05875c8266e2161913ec53d36557df59/flatlaf-demo/DemoLaf.properties#L1-L13
For the above screenshot I only changed @background=#ccc
to @background=#fff
.
See FlatLightLaf.properties
for other UI defaults used in Light theme:
https://github.com/JFormDesigner/FlatLaf/blob/master/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties
Currently there is no documentation of the FlatLaf properties (coming soon), but it should be easy to understand.
To use a properties file in the own application either use class FlatPropertiesLaf or create a subclass of FlatLightLaf with the same base name as the properties file and in the same package as the properties file. See FlatIntelliJLaf.
Thanks @DevCharly, the properties with the subclass did the trick! 🙂
On a related note, I saw the article of a Swing application with FlatLaf running on Webswing, thus becoming a web application. Maybe you should offer one (or several?) light themes that look good for such cases. I find that a gray background does not look modern nor "web" when in a web browser. Maybe it is a matter of taste...
Out of curiosity I gave it a try and here is the FlatLaf demo using Webswing and the default light theme:
And here is the same with the property file you suggested:
I saw the article of a Swing application with FlatLaf running on Webswing
We do exactly that, to demo the application to interested users without requiring an install. I absolutely love that combination!