Example usage for javax.swing ButtonGroup remove

List of usage examples for javax.swing ButtonGroup remove

Introduction

In this page you can find the example usage for javax.swing ButtonGroup remove.

Prototype

public void remove(AbstractButton b) 

Source Link

Document

Removes the button from the group.

Usage

From source file:Main.java

/**
 * Removes all buttons from a button group.
 * @param group the button group/* w ww.j  a  v a  2s  .c  o m*/
 */
public static void clearButtonGroup(ButtonGroup group) {
    while (group.getElements().hasMoreElements()) {
        group.remove(group.getElements().nextElement());
    }
}

From source file:Main.java

public Main() {
    JRadioButton radMarriedYes = new JRadioButton("Yes?", true);
    JRadioButton radMarriedNo = new JRadioButton("No?", false);
    JRadioButton radGolfYes = new JRadioButton("Yes?", false);
    JRadioButton radGolfNo = new JRadioButton("No?", true);

    ButtonGroup radioGroup1 = new ButtonGroup();
    ButtonGroup radioGroup2 = new ButtonGroup();

    setLayout(null);/*  w w  w .  j  av  a2 s.c  o  m*/

    add(radMarriedYes);
    add(radMarriedNo);
    add(radGolfYes);
    add(radGolfNo);

    radioGroup1.add(radMarriedYes);
    radioGroup1.add(radMarriedNo);

    radioGroup1.remove(radMarriedNo);

    radioGroup2.add(radGolfYes);
    radioGroup2.add(radGolfNo);

    radMarriedYes.setBounds(30, 50, 50, 20);
    radMarriedNo.setBounds(30, 80, 50, 20);

    radGolfYes.setBounds(150, 50, 50, 20);
    radGolfNo.setBounds(150, 80, 50, 20);
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Removes all the elements from the passed menu and button group.
 * //w ww.  j  a v a2s .  co m
 * @param group The group to handle.
 * @param menu  The menu to handle.
 */
private void clearZoomMenu(ButtonGroup group, JMenu menu) {
    menu.removeAll();
    for (Enumeration<AbstractButton> e = group.getElements(); e.hasMoreElements();)
        group.remove(e.nextElement());
}