JFormDesigner / FlatLaf

FlatLaf - Swing Look and Feel (with Darcula/IntelliJ themes support)
https://www.formdev.com/flatlaf/
Apache License 2.0
3.42k stars 272 forks source link

Using constants in property files ? #853

Closed MerlinUKRhapsody closed 5 months ago

MerlinUKRhapsody commented 5 months ago

Is it possible to use constants somehow in property files ? I'd like to define a set of colors once and then reference them across different themes. I can do that if I apply the styles programatically using UiManager but I cant seem to find a way to do it using the preferred approach (subclassing FlatLightLaf)

so for example instead of :

Buttons

Button.background = #01416A

I'd like to use

Buttons

Button.background = MY_BUTTON_BG_COLOR

DevCharly commented 5 months ago

You can either use "variables": https://www.formdev.com/flatlaf/properties-files/#variables or "references": https://www.formdev.com/flatlaf/properties-files/#references

DevCharly commented 5 months ago

wrt to the below - how do I reference variables defined in other property files ? If I try to use a variable not defined in 'this' property file I get:

SEVERE: FlatLaf: Failed to parse: 'RootPane.background=@SOWI_SLATE' java.lang.IllegalArgumentException: variable or property '@SOWI_SLATE' not found

And where is @SOWI_SLATE defined? Variables can be defined in any loaded properties file.

See https://www.formdev.com/flatlaf/how-to-customize/#application_properties and https://www.formdev.com/flatlaf/how-to-customize/#properties_load_order

Hard to help with that less information...