From bad0428f5bea3869f6c6b7febff9899b4044efa7 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sat, 20 May 2023 12:09:17 +0200 Subject: [PATCH] UIDefaultsLoader and FlatStylingSupport: explicitly specify `throws IllegalArgumentException` and improved catching --- .../com/formdev/flatlaf/UIDefaultsLoader.java | 144 +++++++++++++----- .../flatlaf/ui/FlatStylingSupport.java | 73 ++++++--- .../flatlaf/UIDefaultsLoaderAccessor.java | 9 +- .../FlatSyntaxTextAreaActions.java | 2 +- .../FlatThemePropertiesSupport.java | 4 +- 5 files changed, 170 insertions(+), 62 deletions(-) diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/UIDefaultsLoader.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/UIDefaultsLoader.java index f6b1691a..b820f000 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/UIDefaultsLoader.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/UIDefaultsLoader.java @@ -271,8 +271,9 @@ class UIDefaultsLoader continue; } - String value = resolveValue( (String) e.getValue(), propertiesGetter ); + String value = (String) e.getValue(); try { + value = resolveValue( value, propertiesGetter ); defaults.put( key, parseValue( key, value, null, null, resolver, addonClassLoaders ) ); } catch( RuntimeException ex ) { logParseError( key, value, ex, true ); @@ -297,7 +298,9 @@ class UIDefaultsLoader LoggingFacade.INSTANCE.logConfig( message, ex ); } - static String resolveValue( String value, Function propertiesGetter ) { + static String resolveValue( String value, Function propertiesGetter ) + throws IllegalArgumentException + { value = value.trim(); String value0 = value; @@ -326,7 +329,9 @@ class UIDefaultsLoader return resolveValue( newValue, propertiesGetter ); } - static String resolveValueFromUIManager( String value ) { + static String resolveValueFromUIManager( String value ) + throws IllegalArgumentException + { if( value.startsWith( VARIABLE_PREFIX ) ) { @SuppressWarnings( "unchecked" ) Map variables = (Map) UIManager.get( KEY_VARIABLES ); @@ -365,12 +370,15 @@ class UIDefaultsLoader private static Map, ValueType> javaValueTypes; private static Map knownValueTypes; - static Object parseValue( String key, String value, Class valueType ) { + static Object parseValue( String key, String value, Class valueType ) + throws IllegalArgumentException + { return parseValue( key, value, valueType, null, v -> v, Collections.emptyList() ); } static Object parseValue( String key, String value, Class javaValueType, ValueType[] resultValueType, Function resolver, List addonClassLoaders ) + throws IllegalArgumentException { if( resultValueType == null ) resultValueType = tempResultValueType; @@ -400,7 +408,7 @@ class UIDefaultsLoader if( value.startsWith( "if(" ) && value.endsWith( ")" ) ) { List params = splitFunctionParams( value.substring( 3, value.length() - 1 ), ',' ); if( params.size() != 3 ) - throwMissingParametersException( value ); + throw newMissingParametersException( value ); boolean ifCondition = parseCondition( params.get( 0 ), resolver, addonClassLoaders ); String ifValue = params.get( ifCondition ? 1 : 2 ); @@ -611,7 +619,9 @@ class UIDefaultsLoader } } - private static Object parseBorder( String value, Function resolver, List addonClassLoaders ) { + private static Object parseBorder( String value, Function resolver, List addonClassLoaders ) + throws IllegalArgumentException + { if( value.indexOf( ',' ) >= 0 ) { // top,left,bottom,right[,lineColor[,lineThickness[,arc]]] List parts = splitFunctionParams( value, ',' ); @@ -671,7 +681,9 @@ class UIDefaultsLoader } } - private static Insets parseInsets( String value ) { + private static Insets parseInsets( String value ) + throws IllegalArgumentException + { List numbers = StringUtils.split( value, ',', true, false ); try { return new InsetsUIResource( @@ -684,7 +696,9 @@ class UIDefaultsLoader } } - private static Dimension parseDimension( String value ) { + private static Dimension parseDimension( String value ) + throws IllegalArgumentException + { List numbers = StringUtils.split( value, ',', true, false ); try { return new DimensionUIResource( @@ -695,7 +709,9 @@ class UIDefaultsLoader } } - private static Object parseColorOrFunction( String value, Function resolver ) { + private static Object parseColorOrFunction( String value, Function resolver ) + throws IllegalArgumentException + { if( value.endsWith( ")" ) ) return parseColorFunctions( value, resolver ); @@ -706,7 +722,9 @@ class UIDefaultsLoader * Parses a hex color in {@code #RGB}, {@code #RGBA}, {@code #RRGGBB} or {@code #RRGGBBAA} * format and returns it as color object. */ - static ColorUIResource parseColor( String value ) { + static ColorUIResource parseColor( String value ) + throws IllegalArgumentException + { int rgba = parseColorRGBA( value ); return ((rgba & 0xff000000) == 0xff000000) ? new ColorUIResource( rgba ) @@ -718,7 +736,9 @@ class UIDefaultsLoader * format and returns it as {@code rgba} integer suitable for {@link java.awt.Color}, * which includes alpha component in bits 24-31. */ - static int parseColorRGBA( String value ) { + static int parseColorRGBA( String value ) + throws IllegalArgumentException + { int len = value.length(); if( (len != 4 && len != 5 && len != 7 && len != 9) || value.charAt( 0 ) != '#' ) throw newInvalidColorException( value ); @@ -759,7 +779,9 @@ class UIDefaultsLoader return new IllegalArgumentException( "invalid color '" + value + "'" ); } - private static Object parseColorFunctions( String value, Function resolver ) { + private static Object parseColorFunctions( String value, Function resolver ) + throws IllegalArgumentException + { int paramsStart = value.indexOf( '(' ); if( paramsStart < 0 ) throw new IllegalArgumentException( "missing opening parenthesis in function '" + value + "'" ); @@ -767,7 +789,7 @@ class UIDefaultsLoader String function = StringUtils.substringTrimmed( value, 0, paramsStart ); List params = splitFunctionParams( value.substring( paramsStart + 1, value.length() - 1 ), ',' ); if( params.isEmpty() ) - throwMissingParametersException( value ); + throw newMissingParametersException( value ); if( parseColorDepth > 100 ) throw new IllegalArgumentException( "endless recursion in color function '" + value + "'" ); @@ -812,9 +834,11 @@ class UIDefaultsLoader * This "if" function is only used if the "if" is passed as parameter to another * color function. Otherwise, the general "if" function is used. */ - private static Object parseColorIf( String value, List params, Function resolver ) { + private static Object parseColorIf( String value, List params, Function resolver ) + throws IllegalArgumentException + { if( params.size() != 3 ) - throwMissingParametersException( value ); + throw newMissingParametersException( value ); boolean ifCondition = parseCondition( params.get( 0 ), resolver, Collections.emptyList() ); String ifValue = params.get( ifCondition ? 1 : 2 ); @@ -826,9 +850,11 @@ class UIDefaultsLoader * - name: system color name * - defaultValue: default color value used if system color is not available */ - private static Object parseColorSystemColor( String value, List params, Function resolver ) { + private static Object parseColorSystemColor( String value, List params, Function resolver ) + throws IllegalArgumentException + { if( params.size() < 1 ) - throwMissingParametersException( value ); + throw newMissingParametersException( value ); ColorUIResource systemColor = getSystemColor( params.get( 0 ) ); if( systemColor != null ) @@ -868,6 +894,7 @@ class UIDefaultsLoader */ private static ColorUIResource parseColorRgbOrRgba( boolean hasAlpha, List params, Function resolver ) + throws IllegalArgumentException { if( hasAlpha && params.size() == 2 ) { // syntax rgba(color,alpha), which allows adding alpha to any color @@ -897,7 +924,9 @@ class UIDefaultsLoader * - lightness: a percentage 0-100% * - alpha: a percentage 0-100% */ - private static ColorUIResource parseColorHslOrHsla( boolean hasAlpha, List params ) { + private static ColorUIResource parseColorHslOrHsla( boolean hasAlpha, List params ) + throws IllegalArgumentException + { int hue = parseInteger( params.get( 0 ), 0, 360, false ); int saturation = parsePercentage( params.get( 1 ) ); int lightness = parsePercentage( params.get( 2 ) ); @@ -917,6 +946,7 @@ class UIDefaultsLoader */ private static Object parseColorHSLIncreaseDecrease( int hslIndex, boolean increase, List params, Function resolver ) + throws IllegalArgumentException { String colorStr = params.get( 0 ); int amount = parsePercentage( params.get( 1 ) ); @@ -960,7 +990,9 @@ class UIDefaultsLoader * - amount: percentage 0-100% * - options: [derived] [lazy] */ - private static Object parseColorFade( List params, Function resolver ) { + private static Object parseColorFade( List params, Function resolver ) + throws IllegalArgumentException + { String colorStr = params.get( 0 ); int amount = parsePercentage( params.get( 1 ) ); boolean derived = false; @@ -994,7 +1026,9 @@ class UIDefaultsLoader * - angle: number of degrees to rotate * - options: [derived] */ - private static Object parseColorSpin( List params, Function resolver ) { + private static Object parseColorSpin( List params, Function resolver ) + throws IllegalArgumentException + { String colorStr = params.get( 0 ); int amount = parseInteger( params.get( 1 ) ); boolean derived = false; @@ -1022,6 +1056,7 @@ class UIDefaultsLoader */ private static Object parseColorChange( int hslIndex, List params, Function resolver ) + throws IllegalArgumentException { String colorStr = params.get( 0 ); int value = (hslIndex == 0) @@ -1050,7 +1085,9 @@ class UIDefaultsLoader * - weight: the weight (in range 0-100%) to mix the two colors * larger weight uses more of first color, smaller weight more of second color */ - private static Object parseColorMix( String color1Str, List params, Function resolver ) { + private static Object parseColorMix( String color1Str, List params, Function resolver ) + throws IllegalArgumentException + { int i = 0; if( color1Str == null ) color1Str = params.get( i++ ); @@ -1077,7 +1114,9 @@ class UIDefaultsLoader * - threshold: the threshold (in range 0-100%) to specify where the transition * from "dark" to "light" is (default is 43%) */ - private static Object parseColorContrast( List params, Function resolver ) { + private static Object parseColorContrast( List params, Function resolver ) + throws IllegalArgumentException + { String colorStr = params.get( 0 ); String darkStr = params.get( 1 ); String lightStr = params.get( 2 ); @@ -1103,7 +1142,9 @@ class UIDefaultsLoader * the alpha of this color is used as weight to mix the two colors * - background: a background color (e.g. #f00) or a color function */ - private static ColorUIResource parseColorOver( List params, Function resolver ) { + private static ColorUIResource parseColorOver( List params, Function resolver ) + throws IllegalArgumentException + { String foregroundStr = params.get( 0 ); String backgroundStr = params.get( 1 ); @@ -1127,6 +1168,7 @@ class UIDefaultsLoader private static Object parseFunctionBaseColor( String colorStr, ColorFunction function, boolean derived, Function resolver ) + throws IllegalArgumentException { // parse base color String resolvedColorStr = resolver.apply( colorStr ); @@ -1158,7 +1200,9 @@ class UIDefaultsLoader /** * Syntax: [normal] [bold|+bold|-bold] [italic|+italic|-italic] [|+|-|%] [family[, family]] [$baseFontKey] */ - private static Object parseFont( String value ) { + private static Object parseFont( String value ) + throws IllegalArgumentException + { Object font = fontCache.get( value ); if( font != null ) return font; @@ -1256,7 +1300,9 @@ class UIDefaultsLoader return font; } - private static int parsePercentage( String value ) { + private static int parsePercentage( String value ) + throws IllegalArgumentException, NumberFormatException + { if( !value.endsWith( "%" ) ) throw new NumberFormatException( "invalid percentage '" + value + "'" ); @@ -1272,7 +1318,9 @@ class UIDefaultsLoader return val; } - private static Boolean parseBoolean( String value ) { + private static Boolean parseBoolean( String value ) + throws IllegalArgumentException + { switch( value ) { case "false": return false; case "true": return true; @@ -1280,13 +1328,17 @@ class UIDefaultsLoader throw new IllegalArgumentException( "invalid boolean '" + value + "'" ); } - private static Character parseCharacter( String value ) { + private static Character parseCharacter( String value ) + throws IllegalArgumentException + { if( value.length() != 1 ) throw new IllegalArgumentException( "invalid character '" + value + "'" ); return value.charAt( 0 ); } - private static Integer parseInteger( String value, int min, int max, boolean allowPercentage ) { + private static Integer parseInteger( String value, int min, int max, boolean allowPercentage ) + throws IllegalArgumentException, NumberFormatException + { if( allowPercentage && value.endsWith( "%" ) ) { int percent = parsePercentage( value ); return (max * percent) / 100; @@ -1298,7 +1350,9 @@ class UIDefaultsLoader return integer; } - private static Integer parseInteger( String value ) { + private static Integer parseInteger( String value ) + throws NumberFormatException + { try { return Integer.parseInt( value ); } catch( NumberFormatException ex ) { @@ -1306,7 +1360,9 @@ class UIDefaultsLoader } } - private static Number parseIntegerOrFloat( String value ) { + private static Number parseIntegerOrFloat( String value ) + throws NumberFormatException + { try { return Integer.parseInt( value ); } catch( NumberFormatException ex ) { @@ -1318,7 +1374,9 @@ class UIDefaultsLoader } } - private static Float parseFloat( String value ) { + private static Float parseFloat( String value ) + throws NumberFormatException + { try { return Float.parseFloat( value ); } catch( NumberFormatException ex ) { @@ -1326,35 +1384,45 @@ class UIDefaultsLoader } } - private static ActiveValue parseScaledInteger( String value ) { + private static ActiveValue parseScaledInteger( String value ) + throws NumberFormatException + { int val = parseInteger( value ); return t -> { return UIScale.scale( val ); }; } - private static ActiveValue parseScaledFloat( String value ) { + private static ActiveValue parseScaledFloat( String value ) + throws NumberFormatException + { float val = parseFloat( value ); return t -> { return UIScale.scale( val ); }; } - private static ActiveValue parseScaledInsets( String value ) { + private static ActiveValue parseScaledInsets( String value ) + throws IllegalArgumentException + { Insets insets = parseInsets( value ); return t -> { return UIScale.scale( insets ); }; } - private static ActiveValue parseScaledDimension( String value ) { + private static ActiveValue parseScaledDimension( String value ) + throws IllegalArgumentException + { Dimension dimension = parseDimension( value ); return t -> { return UIScale.scale( dimension ); }; } - private static Object parseGrayFilter( String value ) { + private static Object parseGrayFilter( String value ) + throws IllegalArgumentException + { List numbers = StringUtils.split( value, ',', true, false ); try { int brightness = Integer.parseInt( numbers.get( 0 ) ); @@ -1415,7 +1483,7 @@ class UIDefaultsLoader return value; } - private static void throwMissingParametersException( String value ) { - throw new IllegalArgumentException( "missing parameters in function '" + value + "'" ); + private static IllegalArgumentException newMissingParametersException( String value ) { + return new IllegalArgumentException( "missing parameters in function '" + value + "'" ); } } diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatStylingSupport.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatStylingSupport.java index de736756..de35b6c3 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatStylingSupport.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatStylingSupport.java @@ -100,15 +100,15 @@ public class FlatStylingSupport /** @since 2 */ public interface StyleableUI { - Map> getStyleableInfos( JComponent c ); - /** @since 2.5 */ Object getStyleableValue( JComponent c, String key ); + Map> getStyleableInfos( JComponent c ) throws IllegalArgumentException; + /** @since 2.5 */ Object getStyleableValue( JComponent c, String key ) throws IllegalArgumentException; } /** @since 2 */ public interface StyleableBorder { Object applyStyleProperty( String key, Object value ); - Map> getStyleableInfos(); - /** @since 2.5 */ Object getStyleableValue( String key ); + Map> getStyleableInfos() throws IllegalArgumentException; + /** @since 2.5 */ Object getStyleableValue( String key ) throws IllegalArgumentException; } /** @since 2.5 */ @@ -135,7 +135,9 @@ public class FlatStylingSupport return getStyle( c ) != null || getStyleClass( c ) != null; } - public static Object getResolvedStyle( JComponent c, String type ) { + public static Object getResolvedStyle( JComponent c, String type ) + throws IllegalArgumentException + { Object style = getStyle( c ); Object styleClass = getStyleClass( c ); Object styleForClasses = getStyleForClasses( styleClass, type ); @@ -175,7 +177,9 @@ public class FlatStylingSupport * @param type the type of the component * @return the styles */ - public static Object getStyleForClasses( Object styleClass, String type ) { + public static Object getStyleForClasses( Object styleClass, String type ) + throws IllegalArgumentException + { if( styleClass == null ) return null; @@ -198,7 +202,9 @@ public class FlatStylingSupport return null; } - private static Object getStyleForClass( String styleClass, String type ) { + private static Object getStyleForClass( String styleClass, String type ) + throws IllegalArgumentException + { return joinStyles( UIManager.get( "[style]." + styleClass ), UIManager.get( "[style]" + type + '.' + styleClass ) ); @@ -218,7 +224,9 @@ public class FlatStylingSupport * @return new joined style */ @SuppressWarnings( "unchecked" ) - public static Object joinStyles( Object style1, Object style2 ) { + public static Object joinStyles( Object style1, Object style2 ) + throws IllegalArgumentException + { if( style1 == null ) return style2; if( style2 == null ) @@ -380,7 +388,9 @@ public class FlatStylingSupport return map; } - private static Object parseValue( String key, String value ) { + private static Object parseValue( String key, String value ) + throws IllegalArgumentException + { // simple reference if( value.startsWith( "$" ) ) return UIManager.get( value.substring( 1 ) ); @@ -475,7 +485,9 @@ public class FlatStylingSupport } } - private static Object applyToField( Field f, Object obj, Object value, boolean useMethodHandles ) { + private static Object applyToField( Field f, Object obj, Object value, boolean useMethodHandles ) + throws IllegalArgumentException + { checkValidField( f ); if( useMethodHandles && obj instanceof StyleableLookupProvider ) { @@ -505,7 +517,9 @@ public class FlatStylingSupport } } - private static Object getFieldValue( Field f, Object obj, boolean useMethodHandles ) { + private static Object getFieldValue( Field f, Object obj, boolean useMethodHandles ) + throws IllegalArgumentException + { checkValidField( f ); if( useMethodHandles && obj instanceof StyleableLookupProvider ) { @@ -530,7 +544,9 @@ public class FlatStylingSupport return new IllegalArgumentException( "failed to access field '" + f.getDeclaringClass().getName() + "." + f.getName() + "'", ex ); } - private static void checkValidField( Field f ) { + private static void checkValidField( Field f ) + throws IllegalArgumentException + { if( !isValidField( f ) ) throw new IllegalArgumentException( "field '" + f.getDeclaringClass().getName() + "." + f.getName() + "' is final or static" ); } @@ -540,7 +556,9 @@ public class FlatStylingSupport return (modifiers & (Modifier.FINAL|Modifier.STATIC)) == 0 && !f.isSynthetic(); } - private static Field getStyleableField( StyleableField styleableField ) { + private static Field getStyleableField( StyleableField styleableField ) + throws IllegalArgumentException + { String fieldName = styleableField.fieldName(); if( fieldName.isEmpty() ) fieldName = styleableField.key(); @@ -648,6 +666,7 @@ public class FlatStylingSupport static Object applyToAnnotatedObjectOrBorder( Object obj, String key, Object value, JComponent c, AtomicBoolean borderShared ) + throws IllegalArgumentException { try { return applyToAnnotatedObject( obj, key, value ); @@ -696,7 +715,9 @@ public class FlatStylingSupport }; } - static Border cloneBorder( Border border ) { + static Border cloneBorder( Border border ) + throws IllegalArgumentException + { Class borderClass = border.getClass(); try { return borderClass.getDeclaredConstructor().newInstance(); @@ -705,7 +726,9 @@ public class FlatStylingSupport } } - static Icon cloneIcon( Icon icon ) { + static Icon cloneIcon( Icon icon ) + throws IllegalArgumentException + { Class iconClass = icon.getClass(); try { return iconClass.getDeclaredConstructor().newInstance(); @@ -718,11 +741,15 @@ public class FlatStylingSupport * Returns a map of all fields annotated with {@link Styleable}. * The key is the name of the field and the value the type of the field. */ - public static Map> getAnnotatedStyleableInfos( Object obj ) { + public static Map> getAnnotatedStyleableInfos( Object obj ) + throws IllegalArgumentException + { return getAnnotatedStyleableInfos( obj, null ); } - public static Map> getAnnotatedStyleableInfos( Object obj, Border border ) { + public static Map> getAnnotatedStyleableInfos( Object obj, Border border ) + throws IllegalArgumentException + { Map> infos = new StyleableInfosMap<>(); collectAnnotatedStyleableInfos( obj, infos ); collectStyleableInfos( border, infos ); @@ -733,7 +760,9 @@ public class FlatStylingSupport * Search for all fields annotated with {@link Styleable} and add them to the given map. * The key is the name of the field and the value the type of the field. */ - public static void collectAnnotatedStyleableInfos( Object obj, Map> infos ) { + public static void collectAnnotatedStyleableInfos( Object obj, Map> infos ) + throws IllegalArgumentException + { HashSet processedFields = new HashSet<>(); Class cls = obj.getClass(); @@ -811,7 +840,9 @@ public class FlatStylingSupport infos.put( keyPrefix.concat( e.getKey() ), e.getValue() ); } - public static Object getAnnotatedStyleableValue( Object obj, String key ) { + public static Object getAnnotatedStyleableValue( Object obj, String key ) + throws IllegalArgumentException + { String fieldName = keyToFieldName( key ); Class cls = obj.getClass(); @@ -878,7 +909,9 @@ public class FlatStylingSupport extends LinkedHashMap { @Override - public V put( K key, V value ) { + public V put( K key, V value ) + throws IllegalArgumentException + { V oldValue = super.put( key, value ); if( oldValue != null ) throw new IllegalArgumentException( "duplicate key '" + key + "'" ); diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/UIDefaultsLoaderAccessor.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/UIDefaultsLoaderAccessor.java index af0ce531..a1093b39 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/UIDefaultsLoaderAccessor.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/UIDefaultsLoaderAccessor.java @@ -50,12 +50,15 @@ public class UIDefaultsLoaderAccessor public static Object NULL = ValueType.NULL; public static Object LAZY = ValueType.LAZY; - public static String resolveValue( String value, Function propertiesGetter ) { + public static String resolveValue( String value, Function propertiesGetter ) + throws IllegalArgumentException + { return UIDefaultsLoader.resolveValue( value, propertiesGetter ); } public static Object parseValue( String key, String value, Object[] resultValueType, Function resolver ) + throws IllegalArgumentException { ValueType[] resultValueType2 = new ValueType[1]; Object result = UIDefaultsLoader.parseValue( key, value, null, @@ -64,7 +67,9 @@ public class UIDefaultsLoaderAccessor return result; } - public static int parseColorRGBA( String value ) { + public static int parseColorRGBA( String value ) + throws IllegalArgumentException + { return UIDefaultsLoader.parseColorRGBA( value ); } } diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatSyntaxTextAreaActions.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatSyntaxTextAreaActions.java index 2ce3829c..75cf46c4 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatSyntaxTextAreaActions.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatSyntaxTextAreaActions.java @@ -376,7 +376,7 @@ class FlatSyntaxTextAreaActions dialog.setVisible( true ); lastLocation = dialog.getLocation(); - } catch( BadLocationException | IndexOutOfBoundsException | NumberFormatException ex ) { + } catch( BadLocationException | IndexOutOfBoundsException | IllegalArgumentException ex ) { ex.printStackTrace(); } } diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java index 0be381c8..97339783 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java @@ -82,7 +82,9 @@ class FlatThemePropertiesSupport this.basePropertyProvider = basePropertyProvider; } - private String resolveValue( String value ) { + private String resolveValue( String value ) + throws IllegalArgumentException + { return UIDefaultsLoaderAccessor.resolveValue( value, propertiesGetter ); }