Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.*;

public class Main {
    public static Component getDescendantWithName(Component c, String name) {
        if (c.getName() != null && c.getName().equals(name))
            return c;
        if (c instanceof Container) {
            for (int i = 0; i < ((Container) c).getComponentCount(); i++) {
                Component out = getDescendantWithName(((Container) c).getComponent(i), name);
                if (out != null)
                    return out;
            }
            return null;
        } else
            return null;
    }
}