From ac291b688df442061dd63f10237b94c7c5a6bc8b Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Mon, 5 Jul 2021 22:40:55 +0200 Subject: [PATCH] Styling: fixed detection of value type if key prefix ix given (e.g. `[light]padding`) --- .../main/java/com/formdev/flatlaf/ui/FlatStyleSupport.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatStyleSupport.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatStyleSupport.java index 902f79b3..2108c077 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatStyleSupport.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatStyleSupport.java @@ -114,6 +114,7 @@ public class FlatStyleSupport String key = e.getKey(); Object newValue = e.getValue(); + // handle key prefix if( key.startsWith( "[" ) ) { if( (SystemInfo.isWindows && key.startsWith( "[win]" )) || (SystemInfo.isMacOS && key.startsWith( "[mac]" )) || @@ -182,6 +183,11 @@ public class FlatStyleSupport if( value.startsWith( "$" ) ) return UIManager.get( value.substring( 1 ) ); + // remove key prefix for correct value type detection + // (e.g. "[light]padding" would not parse to Insets) + if( key.startsWith( "[" ) ) + key = key.substring( key.indexOf( ']' ) + 1 ); + return FlatLaf.parseDefaultsValue( key, value ); }