Here you can find the source of lookupButton(Container c, String text)
Parameter | Description |
---|---|
c | a parameter |
text | a parameter |
private static JButton lookupButton(Container c, String text)
//package com.java2s; //License from project: GNU General Public License import java.awt.Component; import java.awt.Container; import javax.swing.JButton; public class Main { /**/* w w w .ja va 2 s. com*/ * Find button by text * * @param c * @param text * @return */ private static JButton lookupButton(Container c, String text) { JButton button = null; for (Component comp : c.getComponents()) { if (comp == null) { continue; } if (comp instanceof JButton && (button = (JButton) comp).getText() != null && button.getText().equals(text)) { return button; } else if (comp instanceof Container) { if ((button = lookupButton((Container) comp, text)) != null) { return button; } } } return button; } }