void (JComponent c, boolean enabled) { c.setEnabled(enabled); Component[] children = c.getComponents(); for (Component child : children) { if (child instanceof JComponent) { setEnabled((JComponent)child, enabled); } } }