Java JButton Settings parseLevel(ButtonGroup buttonGroup)

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

Description

parse Level

License

Open Source License

Declaration

private static int parseLevel(ButtonGroup buttonGroup) 

Method Source Code


//package com.java2s;
//License from project: GNU General Public License 

import javax.swing.AbstractButton;

import javax.swing.ButtonGroup;

import java.util.Enumeration;

public class Main {
    private static int parseLevel(ButtonGroup buttonGroup) {
        Enumeration<AbstractButton> buttonEnumeration = buttonGroup.getElements();
        while (buttonEnumeration.hasMoreElements()) {
            AbstractButton abstractButton = buttonEnumeration.nextElement();
            if (abstractButton.isSelected()) {
                String buttonText = abstractButton.getText();
                final int index = buttonText.indexOf(" (");
                if (index != -1) {
                    buttonText = buttonText.substring(0, index);
                }/*from www  .  java  2s.  co m*/
                return Integer.parseInt(buttonText);
            }
        }
        return -1;
    }
}

Related

  1. lookupButton(Container c, String text)
  2. newTabbedPaneButton(String text)
  3. numberButtonGroup(ButtonGroup buttonGroup)
  4. opacityCheck(AbstractButton b)
  5. paintClassicText(AbstractButton b, Graphics g, int x, int y, String text, int mnemIndex)
  6. removeAllActionListeners(AbstractButton btn)
  7. removeButtonBorder(AbstractButton button)
  8. removeCloseButton(Component comp)
  9. removeListeners(AbstractButton button)