private static Object applyToField( Object obj, String fieldName, String key, Object value, Predicate<Field> predicate )
		throws UnknownStyleException, IllegalArgumentException
	{
		Class<?> cls = obj.getClass();

		for(;;) {
			try {
				Field f = cls.getDeclaredField( fieldName );
				if( predicate == null || predicate.test( f ) )
					return applyToField( f, obj, value, false );
			} catch( NoSuchFieldException ex ) {
				// field not found in class --> try superclass
			}

			for( StyleableField styleableField : cls.getAnnotationsByType( StyleableField.class ) ) {
				if( key.equals( styleableField.key() ) )
					return applyToField( getStyleableField( styleableField ), obj, value, true );
			}

			cls = cls.getSuperclass();
			if( cls == null )
				throw new UnknownStyleException( key );

			if( predicate != null ) {
				String superclassName = cls.getName();
				if( superclassName.startsWith( "java." ) || superclassName.startsWith( "javax." ) )
					throw new UnknownStyleException( key );
			}
		}
	}
Applies the given value to a field of the given object.

@param obj the object
@param fieldName the name of the field
@param key the key (only used for error reporting)
@param value the new value
@return the old value of the field
@throws UnknownStyleException if object does not have a field with given name
@throws IllegalArgumentException if value type does not fit to expected type
flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatStylingSupport.java