Java tutorial
//package com.java2s; import java.awt.Component; import java.awt.Container; public class Main { public static void setRecursivelyEnabled(Component c, boolean b) { c.setEnabled(b); if (c instanceof Container) { for (Component child : ((Container) c).getComponents()) { setRecursivelyEnabled(child, b); } } } }