public static JButton findButtonByIcon(Container container, Icon icon) {
		Component[] comps = container.getComponents();
		for (Component element : comps) {
			if (element instanceof JButton) {
				JButton button = (JButton) element;
				Icon buttonIcon = button.getIcon();
				if (icon.equals(buttonIcon)) {
					return button;
				}
			}
			else if (element instanceof Container) {
				JButton button = findButtonByIcon((Container) element, icon);
				if (button != null) {
					return button;
				}
			}
		}
		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