public static Component findComponentByName(Container container, String componentName,
			boolean checkOwnedWindows) {

		String containerName = container.getName();

		if (containerName != null && container.getName().equals(componentName)) {
			return container;
		}

		Component[] comps = container.getComponents();
		for (Component element : comps) {
			if (element == null) {
				continue;// this started happening in 1.6, not sure why
			}
			String name = element.getName();
			if (name != null && name.equals(componentName)) {
				return element;
			}
			else if (element instanceof Container) {
				Component comp =
					findComponentByName((Container) element, componentName, checkOwnedWindows);
				if (comp != null) {
					return comp;
				}
			}
		}
		if (checkOwnedWindows && (container instanceof Window)) {
			Window[] windows = ((Window) container).getOwnedWindows();
			for (int i = windows.length - 1; i >= 0; i--) {
				Component c = findComponentByName(windows[i], componentName, checkOwnedWindows);
				if (c != null) {
					return c;
				}
			}
		}
		return null;
	}
Searches the subcomponents of the indicated container and returns the
component with the specified name.

@param container the container to search
@param componentName the name of the desired component

@return the component, or null if not found
Ghidra/Framework/Gui/src/main/java/generic/test/AbstractGuiTest.java