Java tutorial
//package com.java2s; //License from project: Apache License import java.awt.Component; import java.awt.Container; public class Main { static void setDescendantsEnabled(final Component component, final boolean enabled) { if (component != null) { component.setEnabled(enabled); if (component instanceof Container) { final Container container = (Container) component; for (final Component child : container.getComponents()) { setDescendantsEnabled(child, enabled); } } } } }