Example usage for javax.swing ButtonModel setSelected

List of usage examples for javax.swing ButtonModel setSelected

Introduction

In this page you can find the example usage for javax.swing ButtonModel setSelected.

Prototype

public void setSelected(boolean b);

Source Link

Document

Selects or deselects the button.

Usage

From source file:org.rdv.viz.image.ImageViz.java

/**
 * Select the correct radio button for the maximum number of filmstrip images.
 *//*  w ww  .  jav a2  s .c  o  m*/
private void updateMaximumFilmstripImagesRadioButtons() {
    int maximumFilmstripImages = filmstripPanel.getMaximumImages();
    int index = Arrays.binarySearch(MAXIMUM_FILMSTRIP_IMAGES_VALUES, maximumFilmstripImages);
    if (index >= 0) {
        Enumeration<AbstractButton> elements = maximumFilmstripImagesButtonGroup.getElements();
        AbstractButton button = null;
        while (index-- >= 0) {
            button = elements.nextElement();
        }

        maximumFilmstripImagesButtonGroup.setSelected(button.getModel(), true);
    } else {
        ButtonModel buttonModel = maximumFilmstripImagesButtonGroup.getSelection();
        if (buttonModel != null) {
            buttonModel.setSelected(false);
        }
    }

}