Java JButton Settings SelectedOptionButton(Container container)

Here you can find the source of SelectedOptionButton(Container container)

Description

Selected Option Button

License

Open Source License

Declaration

public static String SelectedOptionButton(Container container) 

Method Source Code

//package com.java2s;
/*/*w  ww . j  a v  a 2s  .  c  om*/
 Part of the Papilio Loader

 Copyright (c) 2010-11 GadgetFactory LLC

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License version 2
 as published by the Free Software Foundation.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software Foundation,
 Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

import java.awt.Component;
import java.awt.Container;

import javax.swing.JRadioButton;

public class Main {
    public static String SelectedOptionButton(Container container) {
        for (Component optIterator : container.getComponents()) {
            if (optIterator instanceof JRadioButton) {
                JRadioButton optSelected = (JRadioButton) optIterator;
                if (optSelected.isSelected()) {
                    return optSelected.getActionCommand();
                }
            }
        }
        return "";
    }
}

Related

  1. removeCloseButton(Component comp)
  2. removeListeners(AbstractButton button)
  3. scaleAllAbstractButtonIconsOf(Container container, int size)
  4. scaleButtonIcon(Icon icon, int size)
  5. ScaleButtonIcon(JToggleButton btn, int width, int height, int fontsize)
  6. selectFile(final int openMode, final String title, final String buttonText, final String lastDirectoryUsed, final Component parent, final String suffix, final String description)
  7. selectWithoutNotifyingListeners(AbstractButton ab, boolean selected)
  8. setAction(AbstractButton btn, ActionListener listener, String actionCommand)
  9. setAllEnabled(final ButtonGroup buttonGroup, final boolean enabled)