Java tutorial
//package com.java2s; import java.awt.Component; import javax.swing.JPanel; public class Main { public static void enableChildren(JPanel panel, Class<?>... classesToIgnore) { for (Component component : panel.getComponents()) { if (component instanceof JPanel) { enableChildren((JPanel) component, classesToIgnore); } else { if (!ignoreClasses(component, classesToIgnore)) { component.setEnabled(true); } } } } private static boolean ignoreClasses(Object o, Class<?>... classes) { if (classes != null) { for (Class<?> c : classes) { if (ignoreClass(o, c)) return true; } } return false; } private static boolean ignoreClass(Object o, Class<?> c) { return c.isAssignableFrom(o.getClass()); } }