boolean (Component component) { if (component instanceof JComponent) { Method method = getMethod(component.getClass(), "validate"); Class<?> type = method == null ? null : method.getDeclaringClass(); return Component.class.equals(type) || Container.class.equals(type); } return true; }