Java JButton Settings buttonGroup(JToggleButton b1, JToggleButton b2)

Here you can find the source of buttonGroup(JToggleButton b1, JToggleButton b2)

Description

Create a button group and add the two buttons to it.

License

Open Source License

Parameter

Parameter Description
b1 Button 1
b2 Button 2

Return

The created button group.

Declaration

public static ButtonGroup buttonGroup(JToggleButton b1, JToggleButton b2) 

Method Source Code

//package com.java2s;
/*// w w w.  j  av  a 2 s.c  o  m
 * Copyright 1997-2016 Unidata Program Center/University Corporation for
 * Atmospheric Research, P.O. Box 3000, Boulder, CO 80307,
 * support@unidata.ucar.edu.
 * 
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or (at
 * your option) any later version.
 * 
 * This library 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 Lesser
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

import javax.swing.ButtonGroup;

import javax.swing.JToggleButton;

public class Main {
    /**
     * Create a button group and add the two buttons to it.
     *
     * @param b1 Button 1
     * @param b2 Button 2
     * @return The created button group.
     */
    public static ButtonGroup buttonGroup(JToggleButton b1, JToggleButton b2) {
        ButtonGroup bg = new ButtonGroup();
        bg.add(b1);
        bg.add(b2);
        return bg;
    }

    /**
     * Create a button group and add the three buttons to it.
     *
     * @param b1 Button 1
     * @param b2 Button 2
     * @param b3 Button 3
     * @return The created button group.
     */
    public static ButtonGroup buttonGroup(JToggleButton b1, JToggleButton b2, JToggleButton b3) {
        ButtonGroup bg = buttonGroup(b1, b2);
        bg.add(b3);
        return bg;
    }

    /**
     * Create a button group and add the three buttons to it.
     *
     * @param b1 Button 1
     * @param b2 Button 2
     * @param b3 Button 3
     * @param b4 Button 3
     * @return The created button group.
     */
    public static ButtonGroup buttonGroup(JToggleButton b1, JToggleButton b2, JToggleButton b3, JToggleButton b4) {
        ButtonGroup bg = buttonGroup(b1, b2, b3);
        bg.add(b4);
        return bg;
    }
}

Related

  1. addRadioButton(JPanel buttonPanel, ButtonGroup group, String buttonName, boolean selected, ActionListener listener)
  2. addToButtonGroup(ButtonGroup bg, T button)
  3. applyDefaultProperties(final Button comp)
  4. askYesNoQuestion(String dlgTitle, String question, Component parent, Object[] buttonTittle)
  5. buttonGroup(AbstractButton b1, AbstractButton b2)
  6. clickButton(final Window window, final String buttonText)
  7. configureOKAndCancelButtons(JPanel panel, Action ok, Action cancel)
  8. configureTextAndMnemonic(AbstractButton button, String text)
  9. confirm(Component comp, String title, String message, int buttons, int type)