Example usage for javax.swing ButtonGroup ButtonGroup

List of usage examples for javax.swing ButtonGroup ButtonGroup

Introduction

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

Prototype

public ButtonGroup() 

Source Link

Document

Creates a new ButtonGroup.

Usage

From source file:algorithm.OpenStegoRandomLSBSteganography.java

/**
 * Buttons to toggle optional compression on and off
 *//*w ww  .  ja  va 2s.c  o m*/
private void initButtons() {
    ButtonGroup buttonGroupCompression = new ButtonGroup();
    buttonGroupCompression.add(trueCompressionButton);
    buttonGroupCompression.add(falseCompressionButton);
    trueCompressionButton.setSelected(true);
}

From source file:MenuSelectionManagerDemo.java

public JMenuBar createMenuBar() {
    JMenuBar menuBar;/*from  ww w  . j  a  v a  2 s .c om*/
    JMenu menu, submenu;
    JMenuItem menuItem;
    JRadioButtonMenuItem rbMenuItem;
    JCheckBoxMenuItem cbMenuItem;

    //Create the menu bar.
    menuBar = new JMenuBar();

    //Build the first menu.
    menu = new JMenu("A Menu");
    menu.setMnemonic(KeyEvent.VK_A);
    menu.getAccessibleContext().setAccessibleDescription("The only menu in this program that has menu items");
    menuBar.add(menu);

    //a group of JMenuItems
    menuItem = new JMenuItem("A text-only menu item", KeyEvent.VK_T);
    //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("This doesn't really do anything");
    menuItem.addActionListener(this);
    menu.add(menuItem);

    ImageIcon icon = createImageIcon("1.gif");
    menuItem = new JMenuItem("Both text and icon", icon);
    menuItem.setMnemonic(KeyEvent.VK_B);
    menuItem.addActionListener(this);
    menu.add(menuItem);

    menuItem = new JMenuItem(icon);
    menuItem.setMnemonic(KeyEvent.VK_D);
    menuItem.addActionListener(this);
    menu.add(menuItem);

    //a group of radio button menu items
    menu.addSeparator();
    ButtonGroup group = new ButtonGroup();

    rbMenuItem = new JRadioButtonMenuItem("A radio button menu item");
    rbMenuItem.setSelected(true);
    rbMenuItem.setMnemonic(KeyEvent.VK_R);
    group.add(rbMenuItem);
    rbMenuItem.addActionListener(this);
    menu.add(rbMenuItem);

    rbMenuItem = new JRadioButtonMenuItem("Another one");
    rbMenuItem.setMnemonic(KeyEvent.VK_O);
    group.add(rbMenuItem);
    rbMenuItem.addActionListener(this);
    menu.add(rbMenuItem);

    //a group of check box menu items
    menu.addSeparator();
    cbMenuItem = new JCheckBoxMenuItem("A check box menu item");
    cbMenuItem.setMnemonic(KeyEvent.VK_C);
    cbMenuItem.addItemListener(this);
    menu.add(cbMenuItem);

    cbMenuItem = new JCheckBoxMenuItem("Another one");
    cbMenuItem.setMnemonic(KeyEvent.VK_H);
    cbMenuItem.addItemListener(this);
    menu.add(cbMenuItem);

    //a submenu
    menu.addSeparator();
    submenu = new JMenu("A submenu");
    submenu.setMnemonic(KeyEvent.VK_S);

    menuItem = new JMenuItem("An item in the submenu");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.ALT_MASK));
    menuItem.addActionListener(this);
    submenu.add(menuItem);

    menuItem = new JMenuItem("Another item");
    menuItem.addActionListener(this);
    submenu.add(menuItem);
    menu.add(submenu);

    //Build second menu in the menu bar.
    menu = new JMenu("Another Menu");
    menu.setMnemonic(KeyEvent.VK_N);
    menu.getAccessibleContext().setAccessibleDescription("This menu does nothing");
    menuBar.add(menu);

    Timer timer = new Timer(ONE_SECOND, new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            MenuElement[] path = MenuSelectionManager.defaultManager().getSelectedPath();
            for (int i = 0; i < path.length; i++) {
                if (path[i].getComponent() instanceof javax.swing.JMenuItem) {
                    JMenuItem mi = (JMenuItem) path[i].getComponent();
                    if ("".equals(mi.getText())) {
                        output.append("ICON-ONLY MENU ITEM > ");
                    } else {
                        output.append(mi.getText() + " > ");
                    }
                }
            }
            if (path.length > 0)
                output.append(newline);
        }
    });
    timer.start();
    return menuBar;
}

From source file:com.googlecode.commons.swing.component.datetime.MiniDateCalendar.java

private void init() {
    final DateFormatSymbols dfs = new DateFormatSymbols(locale);
    CollectionUtils.addAll(this.weekdays, dfs.getShortWeekdays());

    for (int i = 0; i < 7; i++) {
        orderedWeekdays.add(((i + weekDayStart - 1) % 7) + 1);
    }//from www . j  a  va2  s.  c  o  m

    setLayout(new BorderLayout());
    SizeUtils.setAllWidths(this, 150);
    SizeUtils.setAllHeights(this, 180);

    panNorth = new JPanel(new BorderLayout());
    add(panNorth, BorderLayout.NORTH);

    btnPrev = new JButton();
    SizeUtils.setAllWidths(btnPrev, 18);
    SizeUtils.setAllHeights(btnPrev, 18);
    btnPrev.setIcon(DefaultIcons.resultset_previous());
    btnPrev.setMargin(new Insets(0, 0, 0, 0));
    btnPrev.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            onClickPrev();
        }
    });
    panNorth.add(btnPrev, BorderLayout.WEST);

    lblMonth = new JLabel();
    SizeUtils.setMinHeight(lblMonth, 0);
    SizeUtils.setPreferredHeight(lblMonth, 0);
    lblMonth.setHorizontalAlignment(SwingConstants.CENTER);
    panNorth.add(lblMonth, BorderLayout.CENTER);

    btnNext = new JButton();
    btnNext.setIcon(DefaultIcons.resultset_next());
    SizeUtils.setAllWidths(btnNext, 18);
    SizeUtils.setAllHeights(btnNext, 18);
    btnNext.setMargin(new Insets(0, 0, 0, 0));
    btnNext.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            onClickNext();
        }
    });
    panNorth.add(btnNext, BorderLayout.EAST);

    panCenter = new JPanel();
    panCenter.setLayout(new GridLayout(7, 7));
    add(panCenter, BorderLayout.CENTER);

    for (int col = 0; col < 7; col++) {
        JLabel lblDay = new JLabel(weekdays.get(orderedWeekdays.get(col)));
        lblDay.setHorizontalAlignment(SwingConstants.CENTER);
        panCenter.add(lblDay);
    }

    ButtonGroup grp = new ButtonGroup();
    for (int row = 0; row < 6; row++) {
        for (int col = 0; col < 7; col++) {
            final int day = orderedWeekdays.get(col);
            final DayButton btn = createDayButton(day, weekdays.get(day));
            btn.setMargin(new Insets(0, 0, 0, 0));
            btn.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    onClickDay(btn.value);
                }
            });
            days.add(btn);
            grp.add(btn);
            panCenter.add(btn);
        }
    }
    refresh();
}

From source file:org.uncommons.watchmaker.swing.evolutionmonitor.PopulationFitnessView.java

/**
 * Creates the GUI controls for toggling graph display options.
 * @return A component that can be added to the main panel.
 *//* www  .  ja  v  a2  s.  c o m*/
private JComponent createControls(boolean islands) {
    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    allDataButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ev) {
            updateDomainAxisRange();
        }
    });
    String text = "Last " + SHOW_FIXED_GENERATIONS + (islands ? " Epochs" : " Generations");
    JRadioButton recentDataButton = new JRadioButton(text, true);
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(allDataButton);
    buttonGroup.add(recentDataButton);

    controls.add(allDataButton);
    controls.add(recentDataButton);

    final JCheckBox meanCheckBox = new JCheckBox("Show Mean", true);
    meanCheckBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent itemEvent) {
            if (itemEvent.getStateChange() == ItemEvent.SELECTED) {
                dataSet.addSeries(meanSeries);
            } else {
                dataSet.removeSeries(meanSeries);
            }
        }
    });
    controls.add(meanCheckBox);

    invertCheckBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent itemEvent) {
            rangeAxis.setInverted(invertCheckBox.isSelected());
        }
    });
    controls.add(invertCheckBox);

    return controls;
}

From source file:uk.co.petertribble.jkstat.gui.KstatBaseChartFrame.java

/**
 * Create the Sleep for... Menu.//from   w  w  w . j a  v a  2s .c o m
 *
 * @return the Sleep Menu
 */
protected JMenu sleepMenu() {
    JMenu jms = new JMenu(KstatResources.getString("SLEEP.TEXT"));
    jms.setMnemonic(KeyEvent.VK_U);
    sleepItem1 = new JRadioButtonMenuItem(KstatResources.getString("SLEEP.1"));
    sleepItem1.addActionListener(this);
    sleepItem2 = new JRadioButtonMenuItem(KstatResources.getString("SLEEP.2"));
    sleepItem2.addActionListener(this);
    sleepItem5 = new JRadioButtonMenuItem(KstatResources.getString("SLEEP.5"), true);
    sleepItem5.addActionListener(this);
    sleepItem10 = new JRadioButtonMenuItem(KstatResources.getString("SLEEP.10"));
    sleepItem10.addActionListener(this);
    jms.add(sleepItem1);
    jms.add(sleepItem2);
    jms.add(sleepItem5);
    jms.add(sleepItem10);

    ButtonGroup sleepGroup = new ButtonGroup();
    sleepGroup.add(sleepItem1);
    sleepGroup.add(sleepItem2);
    sleepGroup.add(sleepItem5);
    sleepGroup.add(sleepItem10);

    return jms;
}

From source file:com.emental.mindraider.ui.dialogs.AttachmentJDialog.java

/**
 * Concetructor./*from w w  w .  j  a  v  a 2  s .c o  m*/
 * 
 * @param noteResource
 *            The concept resource.
 * @param dragAndDropReference
 *            The drag'n'drop reference.
 */
public AttachmentJDialog(ConceptResource conceptResource, DragAndDropReference dragAndDropReference) {

    super(Messages.getString("AttachmentJDialog.title"));
    this.conceptResource = conceptResource;
    getContentPane().setLayout(new BorderLayout());
    JPanel p, pp;

    p = new JPanel();
    p.setLayout(new BorderLayout());
    JLabel intro = new JLabel("<html>&nbsp;&nbsp;" + Messages.getString("AttachmentJDialog.introduction")
            + "&nbsp;&nbsp;<br><br></html>");
    p.add(intro, BorderLayout.NORTH);
    p.add(new JLabel("<html>&nbsp;&nbsp;" + Messages.getString("AttachmentJDialog.description") + "</html>"),
            BorderLayout.CENTER);
    description = new JTextField(38);
    pp = new JPanel(new FlowLayout(FlowLayout.LEFT));
    pp.add(description);
    p.add(pp, BorderLayout.SOUTH);
    getContentPane().add(p, BorderLayout.NORTH);

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.setBorder(new TitledBorder(Messages.getString("AttachmentJDialog.resource")));

    ButtonGroup attachType = new ButtonGroup();

    JPanel webPanel = new JPanel();
    webPanel.setLayout(new BorderLayout());
    webType = new JRadioButton(Messages.getString("AttachmentJDialog.web"));
    webType.setActionCommand(WEB);
    webType.addActionListener(this);
    webType.setSelected(true);
    attachType.add(webType);
    webPanel.add(webType, BorderLayout.NORTH);
    urlTextField = new JTextField("http://", 35);
    urlTextField.selectAll();
    urlTextField.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
                attach();
            }
        }

        public void keyReleased(KeyEvent keyEvent) {
        }

        public void keyTyped(KeyEvent keyEvent) {
        }
    });
    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.LEFT));
    p.add(new JLabel("   "));
    p.add(urlTextField);
    webPanel.add(p, BorderLayout.SOUTH);
    mainPanel.add(webPanel, BorderLayout.NORTH);

    JPanel localPanel = new JPanel();
    localPanel.setLayout(new BorderLayout());
    JRadioButton localType = new JRadioButton(Messages.getString("AttachmentJDialog.local"));
    localType.setActionCommand(LOCAL);
    localType.addActionListener(this);
    localPanel.add(localType, BorderLayout.NORTH);
    pathTextField = new JTextField(35);
    pathTextField.setEnabled(false);
    browseButton = new JButton(Messages.getString("AttachmentJDialog.browse"));
    browseButton.setToolTipText(Messages.getString("AttachmentJDialog.browseTip"));
    browseButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JFileChooser fc = new JFileChooser();
            fc.setApproveButtonText(Messages.getString("AttachmentJDialog.attach"));
            fc.setControlButtonsAreShown(true);
            fc.setDialogTitle(Messages.getString("AttachmentJDialog.chooseAttachment"));
            fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            int returnVal = fc.showOpenDialog(AttachmentJDialog.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                pathTextField.setText(file.toString());
            }
        }
    });
    browseButton.setEnabled(false);
    pp = new JPanel();
    pp.setLayout(new BorderLayout());
    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.LEFT));
    p.add(new JLabel("   "));
    pp.add(p, BorderLayout.NORTH);
    p.add(pathTextField);
    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p.add(browseButton);
    pp.add(p, BorderLayout.SOUTH);
    localPanel.add(pp, BorderLayout.SOUTH);
    attachType.add(localType);
    mainPanel.add(localPanel, BorderLayout.SOUTH);

    getContentPane().add(mainPanel, BorderLayout.CENTER);

    // buttons
    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.CENTER));
    JButton addButton = new JButton(Messages.getString("AttachmentJDialog.attach"));

    p.add(addButton);
    addButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            attach();
        }
    });
    JButton cancelButton = new JButton(Messages.getString("AttachmentJDialog.cancel"));
    p.add(cancelButton);
    cancelButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            AttachmentJDialog.this.dispose();
        }
    });
    getContentPane().add(p, BorderLayout.SOUTH);

    /*
     * drag and drop initialization
     */
    if (dragAndDropReference != null) {
        if (dragAndDropReference.getType() == DragAndDropReference.BROWSER_LINK) {
            urlTextField.setText(dragAndDropReference.getReference());
            localType.setSelected(false);
            webType.setSelected(true);
            enableWebTypeButtons();
        } else {
            pathTextField.setText(dragAndDropReference.getReference());
            localType.setSelected(true);
            webType.setSelected(false);
            enableLocalTypeButtons();
        }
        description.setText(dragAndDropReference.getTitle());
    }

    pack();
    Gfx.centerAndShowWindow(this);
}

From source file:ca.phon.app.session.RecordFilterPanel.java

private void init() {
    FormLayout layout = new FormLayout("0px, fill:pref:grow",
            "pref, 1dlu, pref, pref, 1dlu, pref, pref, 1dlu, pref, pref");
    CellConstraints cc = new CellConstraints();
    setLayout(layout);//from  w  w  w. ja va2 s . c o m

    radioGrp = new ButtonGroup();

    ButtonAction bAct = new ButtonAction();

    allBtn = new JRadioButton("All records");
    allBtn.setSelected(true);
    allBtn.addActionListener(bAct);
    radioGrp.add(allBtn);

    rangeBtn = new JRadioButton("Specific records");
    rangeBtn.addActionListener(bAct);
    radioGrp.add(rangeBtn);

    speakerBtn = new JRadioButton("Records for participant(s)");
    speakerBtn.addActionListener(bAct);
    radioGrp.add(speakerBtn);

    searchBtn = new JRadioButton("Records from search results");
    searchBtn.addActionListener(bAct);
    radioGrp.add(searchBtn);

    rangeField = new JTextField();
    rangeField.setText("1.." + t.getRecordCount());
    rangeField.setInputVerifier(new RangeVerifier());
    rangeField.setEnabled(false);

    speakerTbl = new JXTable(new ParticipantsTableModel());
    speakerTbl.setVisibleRowCount(2);
    speakerTbl.setEnabled(false);

    searchTbl = new JXTable(new SearchTableModel());
    searchTbl.setVisibleRowCount(4);
    searchTbl.setEnabled(false);
    searchTbl.getColumn(0).setCellRenderer(new QueryNameCellRenderer());
    searchTbl.getColumn(1).setCellRenderer(new DateCellRenderer());
    searchTbl.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    searchTbl.getSelectionModel().addListSelectionListener(new SearchListener());
    if (searchTbl.getModel().getRowCount() > 0) {
        searchTbl.getSelectionModel().setSelectionInterval(0, 0);
    }
    searchTbl.setSortOrder(1, SortOrder.DESCENDING);

    // add components
    add(allBtn, cc.xyw(1, 1, 2));
    add(rangeBtn, cc.xyw(1, 3, 2));
    add(rangeField, cc.xy(2, 4));
    add(speakerBtn, cc.xyw(1, 6, 2));
    add(new JScrollPane(speakerTbl), cc.xy(2, 7));
    add(searchBtn, cc.xyw(1, 9, 2));
    add(new JScrollPane(searchTbl), cc.xy(2, 10));
}

From source file:ca.phon.app.query.SaveQueryDialog.java

private void init() {
    //      final PathExpander pe = new PathExpander();

    nameField = new JTextField();
    nameField.getDocument().addDocumentListener(new DocumentListener() {

        @Override/*from  w  w  w.j  av a  2s  . c o m*/
        public void insertUpdate(DocumentEvent de) {
            updateLocationFields();
        }

        @Override
        public void removeUpdate(DocumentEvent de) {
            updateLocationFields();
        }

        @Override
        public void changedUpdate(DocumentEvent de) {
            updateLocationFields();
        }

    });

    includeFormOptionsBox = new JCheckBox("Include current form settings");
    includeFormOptionsBox.setSelected(true);

    ButtonGroup btnGrp = new ButtonGroup();
    saveInProjectBtn = new JRadioButton("Save in project resources");
    btnGrp.add(saveInProjectBtn);
    saveInUserDirBtn = new JRadioButton("Save in user library");
    btnGrp.add(saveInUserDirBtn);
    saveOtherBtn = new JRadioButton("Save in another location...");
    btnGrp.add(saveOtherBtn);
    saveInUserDirBtn.setSelected(true);

    projSaveLocField = new JLabel();
    //      projSaveLocField.setFont(projSaveLocField.getFont().deriveFont(10.0f));
    libSaveLocField = new JLabel();
    //      libSaveLocField.setFont(libSaveLocField.getFont().deriveFont(10.0f));
    updateLocationFields();

    saveBtn = new JButton("Save");
    saveBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            save();
        }
    });
    super.getRootPane().setDefaultButton(saveBtn);

    cancelBtn = new JButton("Cancel");
    cancelBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            setVisible(false);
        }

    });

    final DialogHeader header = new DialogHeader("Save Query", "");
    JComponent btnBar = ButtonBarBuilder.buildOkCancelBar(saveBtn, cancelBtn);

    final FormLayout formLayout = new FormLayout("3dlu, 12dlu, fill:pref:grow, 3dlu",
            "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref");
    final CellConstraints cc = new CellConstraints();
    setLayout(formLayout);

    add(header, cc.xyw(2, 1, 2));

    add(new JLabel("Name: (without extension)"), cc.xyw(2, 2, 2));
    add(nameField, cc.xy(3, 3));
    add(includeFormOptionsBox, cc.xy(3, 4));

    add(saveInUserDirBtn, cc.xyw(2, 5, 2));
    //      add(libSaveLocField, cc.xy(3, 6));

    add(saveInProjectBtn, cc.xyw(2, 7, 2));
    //      add(projSaveLocField, cc.xy(3, 8));

    add(saveOtherBtn, cc.xyw(2, 9, 2));

    add(btnBar, cc.xyw(2, 10, 2));
}

From source file:com.compomics.cell_coord.gui.controller.summary.VisualizeTracksController.java

/**
 * Initialize main view//  w  w w. j  a v  a 2  s. co m
 */
private void initVisualizeTracksPanel() {
    // create new view object
    visualizeTracksPanel = new VisualizeTracksPanel();
    // add radiobuttons to a button group
    ButtonGroup scaleAxesButtonGroup = new ButtonGroup();
    scaleAxesButtonGroup.add(visualizeTracksPanel.getDoNotScaleAxesRadioButton());
    scaleAxesButtonGroup.add(visualizeTracksPanel.getScaleAxesRadioButton());

    // another button group for the shifted/unshifted coordinates
    ButtonGroup shiftedCoordinatesButtonGroup = new ButtonGroup();
    shiftedCoordinatesButtonGroup.add(visualizeTracksPanel.getRawCoordRadioButton());
    shiftedCoordinatesButtonGroup.add(visualizeTracksPanel.getRosePlotRadioButton());

    /**
     * Action Listeners.
     */
    // do not scale the axes
    visualizeTracksPanel.getDoNotScaleAxesRadioButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int nCols = Integer.parseInt((String) visualizeTracksPanel.getnColumnsComboBox().getSelectedItem());
            boolean useRawData = visualizeTracksPanel.getRawCoordRadioButton().isSelected();
            resetPlotLogic();
            generateDataForPlots(useRawData);
            // use the data to set the charts
            setChartsWithCollections(nCols);
        }
    });

    // scale the axes (use a common scale for all the samples)
    visualizeTracksPanel.getScaleAxesRadioButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean useRawData = visualizeTracksPanel.getRawCoordRadioButton().isSelected();
            for (ChartPanel chartPanel : tracksChartPanels) {
                scaleAxes(chartPanel.getChart(), useRawData);
            }
        }
    });

    // plot the raw tracks
    visualizeTracksPanel.getRawCoordRadioButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int nCols = Integer.parseInt((String) visualizeTracksPanel.getnColumnsComboBox().getSelectedItem());
            resetPlotLogic();
            generateDataForPlots(true);
            // use the data to set the charts
            setChartsWithCollections(nCols);
        }
    });

    // make the Rose plot: shift coordinates to origin (zero, zero)
    visualizeTracksPanel.getRosePlotRadioButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int nCols = Integer.parseInt((String) visualizeTracksPanel.getnColumnsComboBox().getSelectedItem());
            resetPlotLogic();
            generateDataForPlots(false);
            // use the data to set the charts
            setChartsWithCollections(nCols);
        }
    });

    // replot with a different number of columns
    visualizeTracksPanel.getnColumnsComboBox().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int nCols = Integer.parseInt((String) visualizeTracksPanel.getnColumnsComboBox().getSelectedItem());
            boolean useRawData = visualizeTracksPanel.getRawCoordRadioButton().isSelected();
            resetPlotLogic();
            generateDataForPlots(useRawData);
            // use the data to set the charts
            setChartsWithCollections(nCols);
        }
    });

    visualizeTracksPanel.getDoNotScaleAxesRadioButton().setSelected(true);
    visualizeTracksPanel.getRawCoordRadioButton().setSelected(true);
    visualizeTracksPanel.getTracksGraphicsParentPanel().revalidate();
    visualizeTracksPanel.getTracksGraphicsParentPanel().repaint();

    // add view to parent controller
    loadTracksController.getMainFrame().getVisualizeTracksParentPanel().add(visualizeTracksPanel,
            gridBagConstraints);
}

From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelChart.java

private JToolBar createChartToolbar() {
    JToolBar toolbar = new JToolBar();

    ButtonGroup groupedButtons = new ButtonGroup();

    // ACTION_CMD_PAN
    chartPanButton = new JToggleButton();
    prepareButton(chartPanButton, ACTION_CHART_PAN, "de/unibayreuth/bayeos/goat/panels/Pan16.gif", "Pan mode");
    groupedButtons.add(chartPanButton);/*from w w  w .j  av a  2s  .  com*/
    toolbar.add(chartPanButton);

    // ACTION_CMD_ZOOM_BOX
    chartZoomButton = new JToggleButton();
    prepareButton(chartZoomButton, ACTION_CHART_ZOOM_BOX, "de/unibayreuth/bayeos/goat/panels/Zoom16.gif",
            "Zoom mode");
    groupedButtons.add(chartZoomButton);
    chartZoomButton.setSelected(true); // no other makes sense after startup
    toolbar.add(chartZoomButton);

    // end of toggle-button group for select/pan/zoom-box
    toolbar.addSeparator();

    // ACTION_CMD_ZOOM_IN
    chartZoomInButton = new JButton();
    prepareButton(chartZoomInButton, ACTION_CHART_ZOOM_IN, "de/unibayreuth/bayeos/goat/panels/ZoomIn16.gif",
            "Zoom in");
    toolbar.add(chartZoomInButton);

    // ACTION_CMD_ZOOM_OUT
    chartZoomOutButton = new JButton();
    prepareButton(chartZoomOutButton, ACTION_CHART_ZOOM_OUT, "de/unibayreuth/bayeos/goat/panels/ZoomOut16.gif",
            "Zoom out");
    toolbar.add(chartZoomOutButton);

    // ACTION_CMD_ZOOM_TO_FIT
    chartFitButton = new JButton();
    prepareButton(chartFitButton, ACTION_CHART_ZOOM_TO_FIT,
            "de/unibayreuth/bayeos/goat/panels/ZoomExtent16.gif", "Zoom to extent");
    toolbar.add(chartFitButton);

    toolbar.addSeparator();

    chartExportButton = new JButton();
    prepareButton(chartExportButton, ACTION_CHART_EXPORT, "de/unibayreuth/bayeos/goat/panels/Export16.gif",
            "Export chart image ...");
    toolbar.add(chartExportButton);

    // ACTION_CMD_PRINT
    chartPrintButton = new JButton();
    prepareButton(chartPrintButton, ACTION_CHART_PRINT, "de/unibayreuth/bayeos/goat/panels/Print16.gif",
            "Print chart ...");
    toolbar.add(chartPrintButton);

    toolbar.addSeparator();
    // ACTION_CMD_PROPERTIES
    chartPropertiesButton = new JButton();
    prepareButton(chartPropertiesButton, ACTION_CHART_PROPERTIES,
            "de/unibayreuth/bayeos/goat/panels/Properties16.gif", "Chart properties ...");
    toolbar.add(chartPropertiesButton);

    chartZoomOutButton.setEnabled(false);
    chartFitButton.setEnabled(false);

    return toolbar;
}