Java tutorial
//package com.java2s; import java.awt.Component; import javax.swing.JComponent; public class Main { public static JComponent match(JComponent c, final String name) { if (c.getName() != null && c.getName().contains(name)) return c; for (Component ci : c.getComponents()) { if (ci instanceof JComponent) { JComponent ret = match((JComponent) ci, name); if (ret != null) return ret; } } return null; } }