Java JButton Settings getSelectedButtonText(ButtonGroup buttonGroup)

Here you can find the source of getSelectedButtonText(ButtonGroup buttonGroup)

Description

get Selected Button Text

License

Open Source License

Declaration

public static String getSelectedButtonText(ButtonGroup buttonGroup) 

Method Source Code

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

import java.util.Enumeration;
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;

public class Main {
    public static String getSelectedButtonText(ButtonGroup buttonGroup) {
        for (Enumeration<AbstractButton> buttons = buttonGroup.getElements(); buttons.hasMoreElements();) {
            AbstractButton button = buttons.nextElement();

            if (button.isSelected()) {
                return button.getText();
            }/*from www  . j  a v a  2 s.c om*/
        }

        return null;
    }

    public static boolean isSelected(AbstractButton... buttons) {
        for (AbstractButton button : buttons) {
            if (button.isSelected()) {
                return true;
            }
        }

        return false;
    }
}

Related

  1. getPreferredButtonSize(AbstractButton b, int textIconGap)
  2. getPreferredButtonSize(AbstractButton b, int textIconGap)
  3. getPressedButtonIcon(int x, int y)
  4. getRadioButtonBorder(int fontSize, boolean ltr)
  5. getSelectedButton(ButtonGroup group)
  6. getSelectedButtonText(ButtonGroup buttonGroup)
  7. getSoftToggleButton(String string)
  8. getTextXOffset(AbstractButton c)
  9. getTogglableIconButton(ImageIcon icon)