Example usage for javax.swing ButtonGroup add

List of usage examples for javax.swing ButtonGroup add

Introduction

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

Prototype

public void add(AbstractButton b) 

Source Link

Document

Adds the button to the group.

Usage

From source file:org.tellervo.desktop.tridasv2.ui.ComponentViewerOld.java

private void initComponents() {
    JLabel label;/*from  ww w .  j av  a2 s .  co  m*/

    setLayout(new BorderLayout());

    // create button panel
    JPanel topPanel = new JPanel();
    label = new JLabel("View as: ");
    btnTreeView = new JRadioButton("tree");
    btnTreeView.putClientProperty("cv.cardName", TREEPANEL);
    btnTableView = new JRadioButton("table");
    btnTableView.putClientProperty("cv.cardName", TABLEPANEL);

    ActionListener btnListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // show the right layout panel
            String v = (String) ((AbstractButton) e.getSource()).getClientProperty("cv.cardName");
            if (v != null)
                ((CardLayout) contentPanel.getLayout()).show(contentPanel, v);
        }
    };
    btnTableView.addActionListener(btnListener);
    btnTreeView.addActionListener(btnListener);

    // connect buttons
    ButtonGroup group = new ButtonGroup();
    group.add(btnTreeView);
    group.add(btnTableView);
    topPanel.setLayout(new MigLayout("", "[64px][55px][62px][63px][][]", "[23px]"));

    // add it all to a panel
    topPanel.add(label, "cell 0 0,alignx left,aligny center");
    topPanel.add(btnTreeView, "cell 1 0,alignx left,aligny center");
    topPanel.add(btnTableView, "cell 2 0,alignx left,aligny center");

    topPanel.setBorder(BorderFactory.createEmptyBorder(2, 8, 8, 8));

    add(topPanel, BorderLayout.NORTH);

    JButton btnOrder = new JButton("Order");
    btnOrder.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

        }

    });
    topPanel.add(btnOrder, "cell 5 0");

    // create status bar
    JPanel status = new JPanel();
    status.setLayout(new BoxLayout(status, BoxLayout.X_AXIS));
    txtStatus = new JLabel("");
    pbStatus = new JProgressBar();
    pbStatus.setVisible(false);
    status.add(txtStatus);
    status.add(Box.createHorizontalStrut(8));
    status.add(pbStatus);
    status.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));

    add(status, BorderLayout.SOUTH);

    contentPanel = new JPanel(new CardLayout());
    add(contentPanel, BorderLayout.CENTER);

    tablePanel = new JPanel(new BorderLayout());
    setupTable();
    tablePanel.add(new JScrollPane(table), BorderLayout.CENTER);

    treePanel = new JPanel(new BorderLayout());
    setupTree();
    treePanel.add(new JScrollPane(tree), BorderLayout.CENTER);

    tree2Panel = new JPanel(new BorderLayout());

    createTree();
    //setupTreeGUI();

    contentPanel.add(tablePanel, TABLEPANEL);
    contentPanel.add(treePanel, TREEPANEL);
    contentPanel.add(tree2Panel, TREE2PANEL);
}

From source file:org.ut.biolab.medsavant.client.annotation.InstallAnnotationWizard.java

@Deprecated
private AbstractWizardPage getAnnotationSourcePage() {
    return new DefaultWizardPage(PAGENAME_SRC) {
        private JRadioButton radioFromRepo = new JRadioButton("MedSavant public repository");
        private JRadioButton radioFromFile = new JRadioButton("file (for custom annotations)");

        {/*from   w w w.j a  va  2 s .c  o  m*/
            ButtonGroup g = new ButtonGroup();
            g.add(radioFromRepo);
            //g.add(radioFromFile);

            final DefaultWizardPage instance = this;
            radioFromRepo.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    setSourceFromRepo(radioFromRepo.isSelected(), instance);
                }
            });

            radioFromFile.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    setSourceFromRepo(radioFromRepo.isSelected(), instance);
                }
            });

            addText("Install annotation from:");
            addComponent(radioFromRepo);
            addComponent(radioFromFile);

            radioFromRepo.setSelected(true);

        }

        @Override
        public void setupWizardButtons() {
            fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH);
            fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.BACK);
            fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.NEXT);
        }
    };
}

From source file:org.ut.biolab.medsavant.client.filter.FilterHistoryPanel.java

public FilterHistoryPanel() {

    FilterController.getInstance().addListener(new Listener<FilterEvent>() {
        @Override//from www . ja v a 2  s .c  o m
        public void handleEvent(final FilterEvent event) {
            new MedSavantWorker<Void>("FilterHistoryPanel") {

                @Override
                protected void showProgress(double fraction) {
                }

                @Override
                protected void showSuccess(Void result) {
                }

                @Override
                protected Void doInBackground() throws Exception {
                    int numLeft = ResultController.getInstance().getFilteredVariantCount();
                    addFilterSet(event.getFilter(), event.getType(), numLeft);
                    return null;
                }

            }.execute();
        }
    });

    ReferenceController.getInstance().addListener(new Listener<ReferenceEvent>() {
        @Override
        public void handleEvent(ReferenceEvent event) {
            if (event.getType() == ReferenceEvent.Type.CHANGED) {
                reset();
            }
        }

    });

    //this.setBackground(new Color(100,100,100));
    this.setBorder(ViewUtil.getMediumBorder());

    this.setMinimumSize(new Dimension(200, 300));
    this.setPreferredSize(new Dimension(200, 300));
    this.setName("History");
    this.setLayout(new BorderLayout());
    table = new JTable() {
        @Override
        public TableCellRenderer getCellRenderer(int row, int column) {
            if (model.getColumnClass(column).equals(JPanel.class)) {
                return new JPanelRenderer();
            }
            return super.getCellRenderer(row, column);
        }
    };
    model = new ProgressTableModel();
    table.setModel(model);

    JPanel modePanel = ViewUtil.getClearPanel();

    ButtonGroup group = new ButtonGroup();
    JRadioButton globalButton = new JRadioButton("Global");
    ViewUtil.makeSmall(globalButton);
    globalButton.setSelected(true);
    globalButton.setOpaque(false);
    JRadioButton relativeButton = new JRadioButton("Relative to previous change");
    ViewUtil.makeSmall(relativeButton);
    relativeButton.setOpaque(false);
    globalButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            changeMode(Mode.GLOBAL);
        }
    });
    relativeButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            changeMode(Mode.RELATIVE);
        }
    });
    group.add(globalButton);
    group.add(relativeButton);
    modePanel.add(globalButton);
    modePanel.add(relativeButton);
    this.add(modePanel, BorderLayout.NORTH);

    final JScrollPane scrollPane = new JScrollPane();
    scrollPane.getViewport().add(table);
    this.add(scrollPane, BorderLayout.CENTER);

    reset();

    //FilterController.addFilterListener(this);

}

From source file:org.ut.biolab.medsavant.client.variant.ImportVariantsWizard.java

private AbstractWizardPage getVCFSourcePage() {
    return new DefaultWizardPage("Location of Files") {
        private JRadioButton onMyComputerButton = new JRadioButton("This computer");
        private JRadioButton onMedSavantServerButton = new JRadioButton("The MedSavant server");

        {//from   w  w w  . ja v  a  2  s .c  om
            ButtonGroup g = new ButtonGroup();
            g.add(onMyComputerButton);
            g.add(onMedSavantServerButton);

            onMyComputerButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    setUploadRequired(onMyComputerButton.isSelected());
                }
            });

            onMedSavantServerButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    setUploadRequired(onMyComputerButton.isSelected());
                }
            });

            addText("The VCFs I want to import are on:");
            addComponent(onMyComputerButton);
            addComponent(onMedSavantServerButton);

            onMyComputerButton.setSelected(true);

        }

        @Override
        public void setupWizardButtons() {
            fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH);
            fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK);
            fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT);
        }
    };
}

From source file:org.ut.biolab.medsavant.client.view.manage.ServerLogPage.java

@Override
public JPanel getView() {
    if (view == null) {
        view = new JPanel();
        view.setLayout(new BorderLayout());

        menuPanel = new JPanel();
        ViewUtil.applyHorizontalBoxLayout(menuPanel);

        ButtonGroup bg = new ButtonGroup();

        JRadioButton b1 = new JRadioButton("Client");
        //JRadioButton b2 = new JRadioButton("Server");
        JRadioButton b3 = new JRadioButton("Annotations");

        bg.add(b1);
        //bg.add(b2);
        bg.add(b3);//w  w  w . j ava  2 s .c  om

        listPanel = new JPanel();
        listPanel.setLayout(new CardLayout());

        listPanel.add(getWaitPanel(), CARDNAME_WAIT);
        listPanel.add(getClientCard(), CARDNAME_CLIENT);
        //listPanel.add(getServerCard(), CARDNAME_SERVER);
        listPanel.add(getAnnotationCard(), CARDNAME_ANNOTATION);

        view.add(menuPanel, BorderLayout.NORTH);
        view.add(listPanel, BorderLayout.CENTER);

        b1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                changeToCard(CARDNAME_CLIENT);

            }
        });
        /*b2.addActionListener(new ActionListener() {
                
        public void actionPerformed(ActionEvent ae) {
            changeToCard(CARDNAME_SERVER);
        }
        });*/
        b3.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                changeToCard(CARDNAME_ANNOTATION);
            }
        });

        b3.setSelected(true);
        this.changeToCard(CARDNAME_ANNOTATION);

        JButton refreshButton = new JButton("Refresh");
        refreshButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                refreshCurrentCard();
            }
        });

        menuPanel.add(Box.createHorizontalGlue());
        menuPanel.add(b3);
        menuPanel.add(b1);
        //menuPanel.add(b2);
        menuPanel.add(refreshButton);
        menuPanel.add(Box.createHorizontalGlue());
    }
    return view;
}

From source file:org.ut.biolab.medsavant.client.view.Menu.java

public void addSection(SectionView section) {

    final JPanel sectionPanel = ViewUtil.getClearPanel();
    sectionPanel.setLayout(new BoxLayout(sectionPanel, BoxLayout.Y_AXIS));
    sectionPanel.setVisible(false);/*from  ww w  .j  a  va 2s. co m*/

    //HoverButton sectionButton = new SectionButton(section, sectionPanel);
    //sectionButton.setSelectedColor(ViewUtil.getSecondaryMenuColor());

    final JToggleButton sectionButton = ViewUtil.getTogglableIconButton(section.getIcon());
    sectionButton.setName(section.getName());
    sectionButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    sectionButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            primaryMenuButtons.setSelected(sectionButton.getModel(), true);
            if (previousSectionPanel != null) {
                previousSectionPanel.setVisible(false);
            }
            // Act as if we clicked the first sub-section button.
            ((SubSectionButton) sectionPanel.getComponent(0)).subSectionClicked();
            sectionPanel.setVisible(true);

            previousSectionPanel = sectionPanel;
            primaryMenu.invalidate();
        }
    });

    ButtonGroup subSectionsGroup = new ButtonGroup();

    for (SubSectionView v : section.getSubSections()) {
        subSectionViews.add(v);

        SubSectionButton subSectionButton = new SubSectionButton(v, subSectionsGroup);
        sectionPanel.add(subSectionButton);
        subSectionsGroup.add(subSectionButton);

        map.put(v, subSectionButton);
    }

    primaryMenuButtons.add(sectionButton);

    sectionPanel.add(Box.createVerticalStrut(50));

    secondaryMenu.add(sectionPanel);

    primaryMenuSectionButtonContainer.add(ViewUtil.subTextComponent(sectionButton, section.getName()));
    primaryMenuSectionButtonContainer.add(ViewUtil.getLargeSeparator());

}

From source file:org.yccheok.jstock.gui.IndicatorPanel.java

/** Creates new instance. */
public IndicatorPanel() {
    ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels");
    initComponents();//from  ww  w. j  ava 2  s  . c  om
    this.jPanel7.add(Utils.getBusyJXLayer((AutoCompleteJComboBox) this.jComboBox1));

    editor = new DefaultDrawingEditor();
    editor.add(view);

    addCreationButtonsTo(creationToolbar, editor);

    JPopupButton pb = new JPopupButton();
    pb.setItemFont(UIManager.getFont("MenuItem.font"));
    labels.configureToolBarButton(pb, "actions");
    pb.add(new GroupAction(editor));
    pb.add(new UngroupAction(editor));
    pb.addSeparator();
    pb.add(new BringToFrontAction(editor));
    pb.add(new SendToBackAction(editor));
    pb.addSeparator();
    pb.add(new SelectAllAction());
    pb.add(new SelectSameAction(editor));
    pb.addSeparator();
    pb.add(new ToggleGridAction(editor));

    JMenu m = new JMenu(labels.getString("zoom"));
    JRadioButtonMenuItem rbmi;
    ButtonGroup group = new ButtonGroup();
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.1, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.25, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.5, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 0.75, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 1.0, null)));
    rbmi.setSelected(true);
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 1.25, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 1.5, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 2, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 3, null)));
    group.add(rbmi);
    m.add(rbmi = new JRadioButtonMenuItem(new ZoomAction(editor, 4, null)));
    group.add(rbmi);
    pb.add(m);
    pb.setFocusable(false);
    creationToolbar.addSeparator();
    creationToolbar.add(pb);

    view.setDrawing(createDrawing());

    stockTask = null;

    initIndicatorProjectManager();
    initModuleProjectManager();
    // Must be done after project managers had been initialized.
    initListCellRenderer();
    createToolTipTextForJTabbedPane();
}

From source file:org.yccheok.jstock.gui.JStock.java

private void jMenu8MenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_jMenu8MenuSelected
    this.jMenu8.removeAll();
    final java.util.List<String> portfolioNames = org.yccheok.jstock.portfolio.Utils.getPortfolioNames();
    final String currentPortfolioName = this.getJStockOptions().getPortfolioName();
    final javax.swing.ButtonGroup buttonGroup = new javax.swing.ButtonGroup();
    for (String portfolioName : portfolioNames) {
        final JMenuItem mi = (JRadioButtonMenuItem) jMenu8.add(new JRadioButtonMenuItem(portfolioName));
        buttonGroup.add(mi);
        mi.addActionListener(new ActionListener() {
            @Override//from  w  w w.  j  a va2s  .  co  m
            public void actionPerformed(ActionEvent e) {
                final String s = ((JRadioButtonMenuItem) e.getSource()).getText();
                if (false == s.equals(currentPortfolioName)) {
                    JStock.this.selectActivePortfolio(s);
                }
            }

        });
        mi.setSelected(portfolioName.equals(currentPortfolioName));
    }

    jMenu8.addSeparator();
    final JMenuItem mi = new JMenuItem(GUIBundle.getString("MainFrame_MultiplePortolio..."),
            this.getImageIcon("/images/16x16/calc.png"));
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            multiplePortfolios();
        }

    });
    jMenu8.add(mi);
}

From source file:org.yccheok.jstock.gui.JStock.java

private void jMenu9MenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_jMenu9MenuSelected
    this.jMenu9.removeAll();
    final java.util.List<String> watchlistNames = org.yccheok.jstock.watchlist.Utils.getWatchlistNames();
    final String currentWatchlistName = this.getJStockOptions().getWatchlistName();
    final javax.swing.ButtonGroup buttonGroup = new javax.swing.ButtonGroup();
    for (String watchlistName : watchlistNames) {
        final JMenuItem mi = (JRadioButtonMenuItem) this.jMenu9.add(new JRadioButtonMenuItem(watchlistName));
        buttonGroup.add(mi);
        mi.addActionListener(new ActionListener() {
            @Override/* www .  j  a  va 2s .c o m*/
            public void actionPerformed(ActionEvent e) {
                final String s = ((JRadioButtonMenuItem) e.getSource()).getText();
                if (false == s.equals(currentWatchlistName)) {
                    JStock.this.selectActiveWatchlist(s);
                }
            }

        });
        mi.setSelected(watchlistName.equals(currentWatchlistName));
    }

    this.jMenu9.addSeparator();
    final JMenuItem mi = new JMenuItem(GUIBundle.getString("MainFrame_MultipleWatchlist..."),
            this.getImageIcon("/images/16x16/stock_timezone.png"));
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            multipleWatchlists();
        }

    });
    this.jMenu9.add(mi);
}

From source file:org.yccheok.jstock.gui.MainFrame.java

private void jMenu8MenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_jMenu8MenuSelected
    this.jMenu8.removeAll();
    final java.util.List<String> portfolioNames = org.yccheok.jstock.portfolio.Utils.getPortfolioNames();
    final String currentPortfolioName = this.getJStockOptions().getPortfolioName();
    final javax.swing.ButtonGroup buttonGroup = new javax.swing.ButtonGroup();
    for (String portfolioName : portfolioNames) {
        final JMenuItem mi = (JRadioButtonMenuItem) jMenu8.add(new JRadioButtonMenuItem(portfolioName));
        buttonGroup.add(mi);
        mi.addActionListener(new ActionListener() {
            @Override//from ww  w.j a v  a 2  s .co m
            public void actionPerformed(ActionEvent e) {
                final String s = ((JRadioButtonMenuItem) e.getSource()).getText();
                if (false == s.equals(currentPortfolioName)) {
                    MainFrame.this.selectActivePortfolio(s);
                }
            }

        });
        mi.setSelected(portfolioName.equals(currentPortfolioName));
    }

    jMenu8.addSeparator();
    final JMenuItem mi = new JMenuItem(GUIBundle.getString("MainFrame_MultiplePortolio..."),
            this.getImageIcon("/images/16x16/calc.png"));
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            multiplePortfolios();
        }

    });
    jMenu8.add(mi);
}