Java 类javax.swing.ButtonGroup 实例源码

项目:PPRCarTrade    文件:TelaBuscarVeiculo.java   
public TelaBuscarVeiculo() {
    initComponents();

    jtb_Veiculos.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    ButtonGroup group = new ButtonGroup();
    group.add(jrb_Marca);
    group.add(jrb_Modelo);
    group.add(jrb_Ano);
    group.add(jrb_MenorPreco);
    group.add(jrb_MaiorPreco);

    DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
    centerRenderer.setHorizontalAlignment( JLabel.CENTER );
    jtb_Veiculos.setDefaultRenderer(Object.class, centerRenderer);

}
项目:Progetto-I    文件:ExecutePage.java   
private void setRadioButtons()
{
    int numeroScelte = progetto.scelteDomandaAttualeSize();
    ArrayList<String> testoScelte = new ArrayList();

    for(int i = 0; i < numeroScelte; i++)
        testoScelte.add(progetto.mostraSceltaDomandaAttuale(i));

    gruppo = new ButtonGroup();

    for(int i = 0; i < numeroScelte; i++)
    {
        JRadioButton radio = new JRadioButton(testoScelte.get(i));
        radio.setFont(fontScelta);
        RadioButtonListener rbl = new RadioButtonListener(progetto);
        radio.addActionListener(rbl);
        gruppo.add(radio);
        center.add(radio);
    }
}
项目:incubator-netbeans    文件:RadioInplaceEditor.java   
public void connect(PropertyEditor pe, PropertyEnv env) {
    if (!tableUI && (env != null) && useTitle) {
        setBorder(new TitledBorder(env.getFeatureDescriptor().getDisplayName()));
    } else {
        setBorder(null);
    }

    editor = pe;

    String[] tags = editor.getTags();
    group = new ButtonGroup();

    InvRadioButton[] buttons = getButtons(tags.length);

    if (env != null) {
        setEnabled(env.isEditable());
    }

    for (int i = 0; i < tags.length; i++) {
        InvRadioButton jr = buttons[i];
        configureButton(jr, tags[i]);
        add(jr);
    }
}
项目:OpenJSharp    文件:MetalThemeMenu.java   
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}
项目:incubator-netbeans    文件:ToolbarPool.java   
/** Updates items in popup menu and returns itself.
*/
public JPopupMenu getContextMenu () {
    removeAll ();

    // generate list of available toolbar panels
    ButtonGroup bg = new ButtonGroup ();
    String current = ToolbarPool.getDefault ().getConfiguration ();
    for( String name : ToolbarPool.getDefault().getConfigurationsNow() ) {
        JRadioButtonMenuItem mi = new JRadioButtonMenuItem (name, (name.compareTo (current) == 0));
        mi.addActionListener (this);
        bg.add (mi);
        this.add (mi);
    }

    return this;
}
项目:freecol    文件:MapEditorMenuBar.java   
private void buildViewMenu() {
    // --> View
    JMenu menu = Utility.localizedMenu("menuBar.view");
    menu.setOpaque(false);
    menu.setMnemonic(KeyEvent.VK_V);

    menu.add(getCheckBoxMenuItem(MapControlsAction.id));
    menu.add(getCheckBoxMenuItem(DisplayGridAction.id));
    menu.add(getCheckBoxMenuItem(ChangeWindowedModeAction.id));

    menu.addSeparator();
    ButtonGroup tileTextGroup = new ButtonGroup();
    for (DisplayText type : DisplayText.values()) {
        menu.add(getRadioButtonMenuItem(DisplayTileTextAction.id + type.getKey(),
                                        tileTextGroup));
    }

    menu.addSeparator();
    menu.add(getMenuItem(ZoomInAction.id));
    menu.add(getMenuItem(ZoomOutAction.id));

    add(menu);
}
项目:incubator-netbeans    文件:ProfilerPopup.java   
public Component getDefaultComponent(Container aContainer) {
    Component c = getFirstComponent(aContainer);

    if (c instanceof AbstractButton) {
        ButtonModel bm = ((AbstractButton)c).getModel();
        if (bm instanceof DefaultButtonModel) {
            ButtonGroup bg = ((DefaultButtonModel)bm).getGroup();
            Enumeration<AbstractButton> en = bg == null ? null : bg.getElements();
            while (en != null && en.hasMoreElements()) {
                AbstractButton ab = en.nextElement();
                if (ab.isSelected()) return ab;
            }
        }
    }

    return c;
}
项目:incubator-netbeans    文件:JWSProjectProperties.java   
private void initRadioButtons() {

    applicationDescButtonModel = new ToggleButtonModel();
    appletDescButtonModel = new ToggleButtonModel();
    compDescButtonModel = new ToggleButtonModel();
    bg = new ButtonGroup();
    applicationDescButtonModel.setGroup(bg);
    appletDescButtonModel.setGroup(bg);
    compDescButtonModel.setGroup(bg);

    String desc = evaluator.getProperty(JNLP_DESCRIPTOR);
    if (desc != null) {
        if (desc.equals(DescType.application.toString())) {
            applicationDescButtonModel.setSelected(true);
        } else if (desc.equals(DescType.applet.toString())) {
            appletDescButtonModel.setSelected(true);
        } else if (desc.equals(DescType.component.toString())) {
            compDescButtonModel.setSelected(true);
        }
    } else {
        applicationDescButtonModel.setSelected(true);
    }

}
项目:rapidminer    文件:ConfigureDataTableHeader.java   
/**
 * @return menu that allows to select possible column types
 */
private JMenu createTypeMenu() {
    ButtonGroup typeGroup = new ButtonGroup();
    JMenu typeChangeItem = new JMenu(CHANGE_TYPE_LABEL);
    typeChangeItem.setToolTipText(CHANGE_TYPE_TIP);
    for (final ColumnType columnType : ColumnType.values()) {
        final JCheckBoxMenuItem checkboxItem = new JCheckBoxMenuItem(
                DataImportWizardUtils.getNameForColumnType(columnType));
        if (columnType == metaData.getColumnMetaData(columnIndex).getType()) {
            checkboxItem.setSelected(true);
        }
        checkboxItem.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    changeType(columnType);
                }

            }
        });
        typeGroup.add(checkboxItem);
        typeChangeItem.add(checkboxItem);
    }
    return typeChangeItem;
}
项目:rapidminer    文件:PerspectiveMenu.java   
private void updatePerspectives(List<Perspective> perspectives) {
    removeAll();
    perspectiveMap.clear();
    workspaceMenuGroup = new ButtonGroup();
    for (Perspective p : perspectives) {
        String name = p.getName();
        Action action = new WorkspaceAction(PerspectiveMenu.this.perspectiveController, p, name);
        if (p.isUserDefined()) {
            action.putValue(Action.ACTION_COMMAND_KEY, "perspective-" + name);
            action.putValue(Action.NAME, name);
            ImageIcon createIcon = SwingTools
                    .createIcon("16/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.workspace_user.icon"));
            action.putValue(Action.LARGE_ICON_KEY, createIcon);
            action.putValue(Action.SMALL_ICON, createIcon);
            action.putValue(Action.SHORT_DESCRIPTION,
                    I18N.getMessage(I18N.getGUIBundle(), "gui.action.workspace_user.tip", name));
        }
        JMenuItem menuItem = new JRadioButtonMenuItem(action);
        add(menuItem);
        perspectiveMap.put(p.getName(), menuItem);
        workspaceMenuGroup.add(menuItem);
    }
    if (perspectiveMap.containsKey(perspectiveName)) {
        perspectiveMap.get(perspectiveName).setSelected(true);
    }
}
项目:ramus    文件:SectorNameEditor.java   
private Component getReplacemetPanel() {
    JPanel group = new JPanel(new GridLayout(0, 1));
    group.setBorder(BorderFactory.createTitledBorder(ResourceLoader
            .getString("ArrowReplacementType.name")));
    group.add(safe = new JRadioButton("ArrowReplacementType.safe"));
    group.add(children = new JRadioButton("ArrowReplacementType.branching"));
    group.add(all = new JRadioButton("ArrowReplacementType.everywhere"));
    safe.setSelected(true);

    ButtonGroup g = new ButtonGroup();
    g.add(children);
    g.add(all);
    g.add(safe);

    setReplaceEnable(false);

    return group;
}
项目:ramus    文件:DocBookScriptReportEditorView.java   
@Override
protected void createButtons(ButtonGroup group) {
    JToggleButton button1 = createOpenViewButton(group, editorView);
    button1.setSelected(true);
    buttonsPanel.add(button1);
    buttonsPanel.add(createOpenViewButton(group, htmlView));
    Iterator<DocBookExporter> iterator = AdditionalPluginLoader
            .loadProviders(DocBookExporter.class);
    while (iterator.hasNext()) {
        final DocBookExporter exporter = iterator.next();
        JButton tb = new JButton();
        tb.setText(exporter.getActionName());
        tb.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                exporter.createReport(getFramework(),
                        new ReportLoadCallback() {

                            @Override
                            public InputStream getDocBookInputStream() {
                                // TODO Auto-generated method stub
                                return null;
                            }
                        });
            }
        });
        buttonsPanel.add(tb);
    }
}
项目:geomapapp    文件:GMAProfile.java   
void initSave() {
    savePanel = new JPanel(new GridLayout(0,1));
    savePanel.setBorder( BorderFactory.createTitledBorder("Save Options"));
    ButtonGroup gp = new ButtonGroup();
    saveToFile = new JToggleButton("Save ASCII table");
    savePanel.add( saveToFile );
    gp.add( saveToFile );
    saveToClipboard = new JToggleButton("Copy to clipboard");
    savePanel.add( saveToClipboard );
    gp.add( saveToClipboard );
    saveJPEG = new JToggleButton("Save JPEG image");
    savePanel.add( saveJPEG );
    gp.add( saveJPEG );
    savePNG = new JToggleButton("Save PNG image");
    savePanel.add( savePNG );
    gp.add( savePNG );
    print = new JToggleButton("Print");
    savePanel.add( print );
    gp.add( print );
}
项目:JuggleMasterPro    文件:PrintIconRadioJButton.java   
public PrintIconRadioJButton(   ControlJFrame objPcontrolJFrame,
                                String strPkey,
                                String strPimage,
                                boolean bolPselected,
                                ButtonGroup objPbuttonGroup,
                                ActionListener objPactionListener) {

    // Create widgets :
    this.objGjLabel =
                        new ExtendedJLabel(objPcontrolJFrame, objPcontrolJFrame .getJuggleMasterPro()
                                                                                .getImageIcon(strPimage, Constants.bytS_UNCLASS_NO_VALUE));
    this.objGjRadioButton = new JRadioButton(Tools.getLocaleString(strPkey));
    this.objGjRadioButton.setFont(objPcontrolJFrame.getFont());
    this.objGjRadioButton.setOpaque(true);
    this.objGjRadioButton.setMnemonic(Tools.getMnemonicChar(strPkey));
    this.objGjRadioButton.addActionListener(objPactionListener);
    this.objGjRadioButton.setSelected(bolPselected);
    objPbuttonGroup.add(this.objGjRadioButton);

    // Add widgets :
    this.setLayout(new FlowLayout(FlowLayout.LEADING));
    this.add(this.objGjLabel);
    this.add(this.objGjRadioButton);
    this.setOpaque(true);
}
项目:FreeCol    文件:MapEditorMenuBar.java   
private void buildViewMenu() {
    // --> View
    JMenu menu = Utility.localizedMenu("menuBar.view");
    menu.setOpaque(false);
    menu.setMnemonic(KeyEvent.VK_V);

    menu.add(getCheckBoxMenuItem(MapControlsAction.id));
    menu.add(getCheckBoxMenuItem(DisplayGridAction.id));
    menu.add(getCheckBoxMenuItem(ChangeWindowedModeAction.id));

    menu.addSeparator();
    ButtonGroup tileTextGroup = new ButtonGroup();
    for (DisplayText type : DisplayText.values()) {
        menu.add(getRadioButtonMenuItem(DisplayTileTextAction.id + type.getKey(),
                                        tileTextGroup));
    }

    menu.addSeparator();
    menu.add(getMenuItem(ZoomInAction.id));
    menu.add(getMenuItem(ZoomOutAction.id));

    add(menu);
}
项目:ramus    文件:NewProjectDialog.java   
@Override
public IPanel getPanel(final int i) {
    if ((i == 0) && (!modelTypeAdded)) {
        ButtonGroup bg = new ButtonGroup();
        idef0.setSelected(true);
        bg.add(idef0);
        bg.add(dfd);
        bg.add(dfds);
        JPanel jPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        jPanel.add(idef0);
        jPanel.add(dfd);
        jPanel.add(dfds);
        JPanel panel = (JPanel) super.getPanel(i);
        panel.add(jPanel, BorderLayout.SOUTH);
        modelTypeAdded = true;
    }
    if (super.getPanelCount() == i) {
        return ouners;
    }
    return super.getPanel(i);
}
项目:Equella    文件:GAbstractButtonGroup.java   
@Override
public JComponent generateControl()
{
    ButtonGroup group = new ButtonGroup();

    JPanel buttons = new JPanel();
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.Y_AXIS));

    Iterator i = items.iterator();
    while( i.hasNext() )
    {
        Item item = (Item) i.next();

        AbstractButton button = generateButton(item.getName(), group);

        item.setButton(button);
        if( item.isSelected() )
        {
            button.setSelected(true);
        }

        buttons.add(button);
    }

    return buttons;
}
项目:JITRAX    文件:MenuBar.java   
private void buildViewMenu() {

    ButtonGroup buttonGroup = new ButtonGroup();

    setCodeHMenu(new JMenu("Code highlighting"));
    raCodeHighLighting = new JCheckBoxMenuItem("Relational Algebra", true);
    sqlCodeHighLighting = new JCheckBoxMenuItem("SQL", true);

    getCodeHMenu().add(raCodeHighLighting);
    getCodeHMenu().add(sqlCodeHighLighting);

    setShowMenu(new JMenu("Show"));
    consoleShow = new JCheckBoxMenuItem("Console", true);
    dbViewerShow = new JCheckBoxMenuItem("DB Viewer", true);
    queriesListShow = new JCheckBoxMenuItem("Query List", true);

    getShowMenu().add(dbViewerShow);
    getShowMenu().add(queriesListShow);
    getShowMenu().add(consoleShow);

    setViewMenu(new JMenu());
    getViewMenu().setMnemonic(KeyEvent.VK_V);
    getViewMenu().add(getCodeHMenu());
    getViewMenu().add(getShowMenu());
}
项目:openjdk-jdk10    文件:MetalThemeMenu.java   
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}
项目:Progetto-I    文件:ExecutePage.java   
private void setRadioButtons()
{
    int numeroScelte = progetto.scelteDomandaAttualeSize();
    ArrayList<String> testoScelte = new ArrayList();

    for(int i = 0; i < numeroScelte; i++)
        testoScelte.add(progetto.mostraSceltaDomandaAttuale(i));

    gruppo = new ButtonGroup();

    for(int i = 0; i < numeroScelte; i++)
    {
        JRadioButton radio = new JRadioButton(testoScelte.get(i));
        radio.setFont(fontScelta);
        RadioButtonListener rbl = new RadioButtonListener(progetto);
        radio.addActionListener(rbl);
        gruppo.add(radio);
        center.add(radio);
    }
}
项目:jdk8u-jdk    文件:MetalThemeMenu.java   
@SuppressWarnings("LeakingThisInConstructor")
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i].
                getName());
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);
        if (i == 0) {
            item.setSelected(true);
        }
    }

}
项目:Equella    文件:AppletGuiUtils.java   
@SuppressWarnings("unchecked")
public BetterGroup(boolean createButtonGroup, Object... objs)
{
    for( int i = 0; i < objs.length; i++ )
    {
        B object = (B) objs[i];
        map.put(object, (V) objs[++i]);
    }
    if( createButtonGroup )
    {
        bg = new ButtonGroup();
        for( B b : map.keySet() )
        {
            bg.add(b);
        }
    }
}
项目:incubator-netbeans    文件:RADComponent.java   
ButtonGroupProperty(RADComponent comp) throws IntrospectionException {
    super(comp,
          new FakePropertyDescriptor("buttonGroup", // NOI18N
                                     javax.swing.ButtonGroup.class));
    setAccessType(DETACHED_READ | DETACHED_WRITE);
    setShortDescription(FormUtils.getBundleString("HINT_ButtonGroup")); // NOI18N
}
项目:incubator-netbeans    文件:RADComponent.java   
@Override
public void restoreDefaultValue() throws IllegalAccessException, InvocationTargetException {
    if (this.getValue() instanceof FormDesignValue) {
        FormDesignValue formValue = (FormDesignValue) this.getValue();

        if (formValue.getDesignValue() instanceof ButtonGroup) {
            AbstractButton button = (AbstractButton) this.getRADComponent().getBeanInstance();
            synchronizeButtonGroupInAWT(button, formValue, null);
        }
    }
    super.restoreDefaultValue();
}
项目:incubator-netbeans    文件:ViewActions.java   
public ViewActions(RuleEditorViews views) {
    actions = new ArrayList<ViewActionSupport>();

    actions.add(new ViewActionSupport.UpdatedOnlyViewAction(views));
    actions.add(new ViewActionSupport.CategorizedViewAction(views));
    actions.add(new ViewActionSupport.AllViewAction(views));

    ButtonGroup group = new ButtonGroup();
    for(ViewActionSupport action : actions) {
        group.add(action.obtainMenuItem());
    }

}
项目:ramus    文件:XMLReportEditorView.java   
@Override
protected void createButtons(ButtonGroup group) {
    JToggleButton button1 = createOpenViewButton(group, editorView);
    button1.setSelected(true);
    buttonsPanel.add(button1);
    buttonsPanel.add(createOpenViewButton(group, queryView));
    super.createButtons(group);
}
项目:intellij-randomness    文件:ButtonGroupHelper.java   
/**
 * Returns the action command of the currently selected button, or {@code null} if no button is selected.
 *
 * @param group a {@code ButtonGroup}
 * @return the {@code String} value of the currently selected button, or {@code null} if no button is selected
 */
public static String getValue(final ButtonGroup group) {
    return Collections.list(group.getElements()).stream()
            .filter(AbstractButton::isSelected)
            .map(AbstractButton::getActionCommand)
            .findFirst()
            .orElse(null);
}
项目:rapidminer    文件:NewRepositoryDialog.java   
private NewRepositoryDialog() {
    super(RapidMinerGUI.getMainFrame(), "repositorydialog", true, new Object[] {});

    Box firstPage = new Box(BoxLayout.Y_AXIS);
    ButtonGroup checkBoxGroup = new ButtonGroup();
    localButton = new JRadioButton(new ResourceActionAdapter("new_local_repositiory"));
    localButton.setSelected(true);

    checkBoxGroup.add(localButton);
    firstPage.add(localButton);

    Map<String, Component> cards = new HashMap<String, Component>();
    cards.put("first", firstPage);
    cards.put("local", localRepositoryPanel);

    // register a radio button for each custom repository type
    for (CustomRepositoryFactory factory : CustomRepositoryRegistry.INSTANCE.getFactories()) {
        String key = factory.getI18NKey();
        RepositoryConfigurationPanel repositoryConfigurationPanel = factory.getRepositoryConfigurationPanel();
        JRadioButton radioButton = new JRadioButton(new ResourceActionAdapter(key));
        radioButton.setEnabled(factory.enableRepositoryConfiguration());
        repoConfigPanels.put(key, new Pair<>(repositoryConfigurationPanel, radioButton));

        checkBoxGroup.add(radioButton);
        firstPage.add(radioButton);

        cards.put(factory.getI18NKey(), repositoryConfigurationPanel.getComponent());
    }

    firstPage.add(Box.createVerticalGlue());
    layoutDefault(cards);
}
项目:intellij-randomness    文件:ButtonGroupHelper.java   
/**
 * Sets the currently selected button to the button with the given action command.
 *
 * @param group a {@code ButtonGroup}
 * @param value an action command
 */
public static void setValue(final ButtonGroup group, final String value) {
    final AbstractButton targetButton = Collections.list(group.getElements()).stream()
            .filter(button -> button.getActionCommand().equals("\0".equals(value) ? "" : value))
            .findFirst()
            .orElseThrow(() -> new NoSuchElementException("Could not find a button with action command `"
                    + value + "`."));

    targetButton.setSelected(true);
}
项目:Equella    文件:ChangeDetector.java   
public void watch(ButtonGroup g)
{
    Enumeration<AbstractButton> e = g.getElements();
    while( e.hasMoreElements() )
    {
        watch(e.nextElement());
    }
}
项目:ramus    文件:PrintPreviewComponent.java   
public JToolBar createToolBar() {
    JToolBar bar = new JToolBar();

    JComboBox zoom = createZoomComboBox();

    for (Action action : getFileActions()) {
        if (action == null)
            bar.addSeparator();
        else
            bar.add(action).setFocusable(false);
    }
    bar.addSeparator();

    JToggleButton grid = new JToggleButton(layoutGridAction);
    grid.setText(null);
    grid.setFocusable(false);

    JToggleButton col = new JToggleButton(layoutColAction);
    col.setText(null);
    col.setFocusable(false);

    ButtonGroup bg = new ButtonGroup();
    bg.add(col);
    bg.add(grid);

    bar.add(grid);
    bar.add(col);
    bar.addSeparator();
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    panel.add(zoom);
    bar.add(panel);
    return bar;
}
项目:2D-Elliptic-Mesh-Generator    文件:DataSelectPanel.java   
void buildRows(int... selectedaxis) {
    ButtonGroup xgrp = new ButtonGroup();
    ButtonGroup ygrp = new ButtonGroup();
    ButtonGroup zgrp = new ButtonGroup();
    rows = new ParameterRow[_parametersNames.length];
    for (int i = 0; i < _parametersNames.length; i++) {
        rows[i] = new ParameterRow(_parametersNames[i], getColumn(i, _data));

        if (selectedaxis != null && selectedaxis.length > 0) {
            if (selectedaxis.length >= 1) {
                rows[i].xaxis.setSelected(selectedaxis[0] == i);
            }
            if (selectedaxis.length >= 2) {
                rows[i].yaxis.setSelected(selectedaxis[1] == i);
            }
            if (selectedaxis.length == 3) {
                rows[i].zaxis.setSelected(selectedaxis[2] == i);
            }
        }

        xgrp.add(rows[i].xaxis);
        ygrp.add(rows[i].yaxis);
        zgrp.add(rows[i].zaxis);

        add(rows[i]);
    }
    setPreferredSize(new Dimension(row_width, row_height * _parametersNames.length));
    setSize(new Dimension(row_width, row_height * _parametersNames.length));

    autoSelectVariableParam();
    updateSelectedData();
}
项目:OpenDA    文件:Query.java   
/** Create a bank of radio buttons.  A radio button provides a list of
 *  choices, only one of which may be chosen at a time.
 *  @param name The name used to identify the entry (when calling get).
 *  @param label The label to attach to the entry.
 *  @param values The list of possible choices.
 *  @param defaultValue Default value.
 */
public void addRadioButtons(
    String name,
    String label,
    String[] values,
    String defaultValue) {
    JLabel lbl = new JLabel(label + ": ");
    lbl.setBackground(_background);
    FlowLayout flow = new FlowLayout();
    flow.setAlignment(FlowLayout.LEFT);

    // This must be a JPanel, not a Panel, or the scroll bars won't work.
    JPanel buttonPanel = new JPanel(flow);

    ButtonGroup group = new ButtonGroup();
    QueryActionListener listener = new QueryActionListener(name);

    // Regrettably, ButtonGroup provides no method to find out
    // which button is selected, so we have to go through a
    // song and dance here...
    JRadioButton[] buttons = new JRadioButton[values.length];
    for (int i = 0; i < values.length; i++) {
        JRadioButton checkbox = new JRadioButton(values[i]);
        buttons[i] = checkbox;
        checkbox.setBackground(_background);
        // The following (essentially) undocumented method does nothing...
        // checkbox.setContentAreaFilled(true);
        checkbox.setOpaque(false);
        if (values[i].equals(defaultValue)) {
            checkbox.setSelected(true);
        }
        group.add(checkbox);
        buttonPanel.add(checkbox);
        // Add the listener last so that there is no notification
        // of the first value.
        checkbox.addActionListener(listener);
    }
    _addPair(name, lbl, buttonPanel, buttons);
}
项目:projetomcdonalds    文件:Remove.java   
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    buttonGroup1 = new javax.swing.ButtonGroup();
    jTabbedPane1 = new javax.swing.JTabbedPane();
    painel_ingrediente = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    lista_ingrediente = new javax.swing.JList();
    lebel_titulo = new javax.swing.JLabel();
    btm_removeIngredientes = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setAlwaysOnTop(true);
    setResizable(false);
    getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

    painel_ingrediente.setLayout(null);

    jScrollPane1.setViewportView(lista_ingrediente);

    painel_ingrediente.add(jScrollPane1);
    jScrollPane1.setBounds(10, 51, 258, 160);

    lebel_titulo.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
    lebel_titulo.setText("Remover Ingrediente");
    painel_ingrediente.add(lebel_titulo);
    lebel_titulo.setBounds(10, 11, 194, 22);

    btm_removeIngredientes.setText("REMOVER");
    painel_ingrediente.add(btm_removeIngredientes);
    btm_removeIngredientes.setBounds(10, 230, 130, 23);

    jTabbedPane1.addTab("Ingredientes", painel_ingrediente);

    getContentPane().add(jTabbedPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 400, 300));

    pack();
}
项目:SASS    文件:ButtonGroupUtils.java   
/**
 * Determines the label of the current selected button.
 * @param buttonGroup
 * @return The text label of the selected button.
 */
public static String getSelectedButtonText(ButtonGroup buttonGroup) {
    for (Enumeration<AbstractButton> buttons = buttonGroup.getElements(); buttons.hasMoreElements();) {
        AbstractButton button = buttons.nextElement();

        if (button.isSelected()) {
            return button.getText();
        }
    }

    return null;
}
项目:scorekeeperfrontend    文件:BaseDialog.java   
/**
 * Create the dialog.
 *
 * @param lm the layout manager to use for the mainPanel
 * @param floatme true to create a non-modal dialog that floats on top of other windows
 */
public BaseDialog(LayoutManager lm, boolean floatme)
{
    super(new BorderLayout());
    valid = false;
    currentDialog = null;
    floating = floatme;

    labels = new HashMap<String,JLabel>();
    fields = new HashMap<String,JTextField>();
    selects = new HashMap<String,JComboBox<Object>>();
    checks = new HashMap<String,JCheckBox>();
    radios = new HashMap<String,JRadioButton>();
    buttonGroup = new ButtonGroup();

    ok = new JButton("OK");
    cancel = new JButton("Cancel");
    ok.addActionListener(this);
    cancel.addActionListener(this);
    defaultButton = ok;

    buttonPanel = new JPanel();
    buttonPanel.add(ok);
    buttonPanel.add(cancel);

    mainPanel = new JPanel(lm);
    mainPanel.setBorder(new EmptyBorder(6,6,6,6));

    add(mainPanel, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);
}
项目:Cognizant-Intelligent-Test-Scripter    文件:CognizantITSSettings.java   
private String getSelectedButton(ButtonGroup bGroup) {
    for (Enumeration<AbstractButton> buttons = bGroup.getElements(); buttons.hasMoreElements();) {
        AbstractButton button = buttons.nextElement();
        if (button.isSelected()) {
            return button.getText();
        }
    }
    return "None";
}
项目:JavaGraph    文件:TypeTree.java   
/** Creates a tool bar for the label tree. */
public JToolBar createToolBar() {
    JToolBar result = Options.createToolBar();
    result.add(getShowSubtypesButton());
    result.add(getShowSupertypesButton());
    result.addSeparator();
    result.add(getShowAllLabelsButton());
    result.add(getCollapseAllButton());
    // put the sub- and supertype buttons in a button group
    ButtonGroup modeButtonGroup = new ButtonGroup();
    modeButtonGroup.add(getShowSubtypesButton());
    modeButtonGroup.add(getShowSupertypesButton());
    return result;
}
项目:JavaGraph    文件:BehaviourOption.java   
/**
 * Constructs a menu with a given name, and either 2 or 3 option values.
 * @param name the name of the behaviour option
 * @param choiceCount the number of values should be either 2 or 3
 */
public BehaviourOption(String name, int choiceCount) {
    super(name);
    if (choiceCount != 2 && choiceCount != 3) {
        throw new IllegalArgumentException(String.format("Number of options cannot be %d",
            choiceCount));
    }
    this.answers = choiceCount == 2 ? standardAnswers2 : standardAnswers3;
    this.answerGroup = new ButtonGroup();
    for (String answer : this.answers) {
        addAnswer(answer);
    }
    getItem(ASK).setSelected(true);
}
项目:json2java4idea    文件:SettingsPanel.java   
public SettingsPanel() {
    styleGroup = new ButtonGroup();
    styleGroup.add(defaultStyleButton);
    styleGroup.add(gsonStyleButton);
    styleGroup.add(jacksonStyleButton);
    styleGroup.add(moshiStyleButton);

    Collections.list(styleGroup.getElements()).forEach(button -> button.addActionListener(this));
    classNamePrefixField.getDocument().addDocumentListener(this);
    classNameSuffixField.getDocument().addDocumentListener(this);

    generatedAnnotationCheckBox.addActionListener(this);
    suppressWarningsAnnotationCheckBox.addActionListener(this);
}