Java JButton Settings getButton(Container c, String text)

Here you can find the source of getButton(Container c, String text)

Description

get Button

License

Open Source License

Declaration

static JButton getButton(Container c, String text) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.*;

import javax.swing.*;

public class Main {
    static JButton getButton(Container c, String text) {
        if (c.isShowing()) {
            if (c.getComponents().length == 0) {
                if (c instanceof JButton) {
                    JButton b = (JButton) c;
                    String btxt = b.getText();
                    if (btxt != null && btxt.equalsIgnoreCase(text)) {
                        return b;
                    }/*w w  w  . j  a  va 2 s  .c  o m*/
                }
            } else {
                for (Component sub : c.getComponents()) {
                    if (sub instanceof Container) {
                        JButton b = getButton((Container) sub, text);
                        if (b != null) {
                            return b;
                        }
                    }
                }
            }
        }
        return null;
    }
}

Related

  1. fixButtonUI(AbstractButton button)
  2. formatButtonFromAction(Action a)
  3. getAbstractButton(Container owner, String text)
  4. getAllButtons(Component topComponent)
  5. getbtnButton(String iconpath, String rolloverIconpath, String pressIconpath)
  6. getButton(Container container, String text)
  7. getButton(String displayText, ActionListener actionListener)
  8. getButtonAsLink(String text)
  9. getButtonBorderColor(Color color)