Java tutorial
//package com.java2s; import java.awt.Component; import javax.swing.JComponent; public class Main { /** * recursive implementation * @param value * @param c */ public static void enable(JComponent c, boolean value) { Component comp[] = c.getComponents(); for (int i = 0; i < comp.length; i++) { comp[i].setEnabled(value); if (comp[i] instanceof JComponent) { enable((JComponent) comp[i], value); } } } }