Here you can find the source of CreateOptionButtonGroup(Box boxGeneric, Border bdrButtonGroup, String[] elements, String[] commandActions, Dimension elementDimension)
public static void CreateOptionButtonGroup(Box boxGeneric, Border bdrButtonGroup, String[] elements, String[] commandActions, Dimension elementDimension)
//package com.java2s; /*//w ww. j a v a2 s . co m 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.Dimension; import javax.swing.Box; import javax.swing.ButtonGroup; import javax.swing.JRadioButton; import javax.swing.border.Border; public class Main { public static void CreateOptionButtonGroup(Box boxGeneric, Border bdrButtonGroup, String[] elements, String[] commandActions, Dimension elementDimension) { ButtonGroup group = new ButtonGroup(); JRadioButton optElement; int i = 0; boxGeneric.setBorder(bdrButtonGroup); for (String iterElement : elements) { optElement = new JRadioButton(iterElement); optElement.setActionCommand(commandActions[i]); if (elementDimension != null) { optElement.setPreferredSize(elementDimension); optElement.setMaximumSize(elementDimension); } boxGeneric.add(optElement); group.add(optElement); i++; } } }