void (@NotNull Object o) { for (Class<?> clazz = o.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) { for (Field field : clazz.getDeclaredFields()) { field.setAccessible(true); try { Object v = field.get(o); if (v instanceof JComponent) { field.set(o, null); } } catch (IllegalAccessException e) { // Ignore } } } }