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:net.sf.firemox.AbstractMainForm.java

/**
 * Initialize the components of this form.
 */// w  w w  .ja v  a 2  s  .com
protected void initAbstractMenu() {
    // "TBS" menu
    tbsMenu = UIHelper.buildMenu("menu_options_tbs");
    ButtonGroup group4 = new ButtonGroup();
    final MdbListener mdbListener = new MdbListener(this);
    final File[] mdbs = MToolKit.getFile(IdConst.TBS_DIR)
            .listFiles((FileFilter) FileFilterUtils.suffixFileFilter("xml"));
    String defaultTbs = MToolKit.tbsName;
    for (File mdb : mdbs) {
        String mdbName = FilenameUtils.getBaseName(mdb.getName());
        JRadioButtonMenuItem itemChck = new JRadioButtonMenuItem();
        MToolKit.tbsName = mdbName;
        updateMdbMenu(mdbName, itemChck);
        itemChck.setActionCommand(mdbName);
        itemChck.setFont(MToolKit.defaultFont);
        itemChck.addActionListener(mdbListener);
        group4.add(itemChck);
        tbsMenu.add(itemChck);
        if (mdbName.equals(defaultTbs)) {
            itemChck.setSelected(true);
        }
    }
    MToolKit.tbsName = defaultTbs;
    tbsMenu.add(new JSeparator());

    // "More TBS" menu item
    tbsMenu.add(UIHelper.buildMenu("menu_options_tbs_more", mdbListener));
    tbsMenu.add(new JSeparator());
    final JMenuItem updateMdbMenu = UIHelper.buildMenu("menu_options_tbs_update", mdbListener);
    updateMdbMenu.setEnabled(false);
    tbsMenu.add(updateMdbMenu);
    tbsMenu.add(UIHelper.buildMenu("menu_options_tbs_rebuild", mdbListener));
    optionMenu.add(new JSeparator());
    optionMenu.add(tbsMenu);
}

From source file:it.cnr.icar.eric.client.ui.swing.metal.MetalThemeMenu.java

/**
 * Constucts a JMenu named 'name' with a a RadioButton for each
 * object in 'themeArray'./*from  ww  w.  j  av  a 2s. co  m*/
 *
 * @param name the visible name for the Menu.
 * @param themeArray the array of themes to put in the menu.
 */
public MetalThemeMenu(String name, MetalTheme[] themeArray) {
    super(name);
    themeNames = ResourceBundle.getBundle(BASE_NAME, Locale.getDefault());
    themes = themeArray;

    ButtonGroup group = new ButtonGroup();
    JRadioButtonMenuItem defaultItem = null;

    for (int i = 0; i < themes.length; i++) {
        String themeName;

        try {
            themeName = themeNames.getString(themes[i].getName().replaceAll("\\s", ""));
        } catch (MissingResourceException mre) {
            themeName = themes[i].getName();

            Object[] noResourceArgs = { themes[i].getName(), getLocale() };
            MessageFormat form = new MessageFormat(themeNames.getString("message.error.noResource"));
            log.error(form.format(noResourceArgs));
        }

        JRadioButtonMenuItem item = new JRadioButtonMenuItem(themeName);
        group.add(item);
        add(item);
        item.setActionCommand(i + "");
        item.addActionListener(this);

        // Theme name without spaces is the key for looking up localized item text.
        item.setName(themes[i].getName().replaceAll(" ", ""));

        if (i == 0) {
            item.setSelected(true);
            defaultItem = item;
        }
    }

    //add listener for 'locale' bound property
    RegistryBrowser.getInstance().addPropertyChangeListener(RegistryBrowser.PROPERTY_LOCALE, this);

    defaultItem.doClick();
}

From source file:com.eviware.soapui.support.components.SimpleForm.java

public JRadioButton appendRadioButton(String caption, String label, ButtonGroup group, boolean selected) {
    JRadioButton radioButton = new JRadioButton(label, selected);
    radioButton.getAccessibleContext().setAccessibleDescription(caption);
    if (group != null) {
        group.add(radioButton);
    }//  w  w w .j  a v  a  2  s . c  om
    components.put(caption, radioButton);
    append(caption, radioButton);
    return radioButton;
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.generic.GenericDoseResponseController.java

/**
 * Initialize main view/*  w  ww. ja  v a  2 s. c o  m*/
 */
@Override
protected void initMainView() {
    genericDRParentPanel = new GenericDRParentPanel();
    dRPanel = new DRPanel();
    //buttons disabled at start
    genericDRParentPanel.getCancelButton().setEnabled(false);
    genericDRParentPanel.getNextButton().setEnabled(false);
    getCardLayout().first(genericDRParentPanel.getContentPanel());
    onCardSwitch();
    //create a ButtonGroup for the radioButtons used for analysis
    ButtonGroup mainDRRadioButtonGroup = new ButtonGroup();
    //adding buttons to a ButtonGroup automatically deselect one when another one gets selected
    mainDRRadioButtonGroup.add(dRPanel.getInputDRButton());
    mainDRRadioButtonGroup.add(dRPanel.getInitialPlotDRButton());
    mainDRRadioButtonGroup.add(dRPanel.getNormalizedPlotDRButton());
    mainDRRadioButtonGroup.add(dRPanel.getResultsDRButton());
    //select as default first button
    dRPanel.getInputDRButton().setSelected(true);
    //init dataTable
    dataTable = new JTable();
    JScrollPane scrollPane = new JScrollPane(dataTable);
    //the table will take all the viewport height available
    dataTable.setFillsViewportHeight(true);
    scrollPane.getViewport().setBackground(Color.white);
    dataTable.getTableHeader().setReorderingAllowed(false);
    //row and column selection must be false
    //dataTable.setColumnSelectionAllowed(false);
    //dataTable.setRowSelectionAllowed(false);
    dRPanel.getDatatableDRPanel().add(scrollPane, BorderLayout.CENTER);
    setLogTransform(true);

    /**
     * Action listeners for uppermost panel.
     */
    //this button is ONLY used when going from the loading to the analysis
    genericDRParentPanel.getNextButton().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            genericDRParentPanel.getNextButton().setEnabled(false);
            genericDRParentPanel.getCancelButton().setEnabled(true);
            //save any metadata that was provided manually
            loadGenericDRDataController.setManualMetaData(importedDRDataHolder);
            //switch between child panels
            getCardLayout().next(genericDRParentPanel.getContentPanel());
            onCardSwitch();
        }
    });

    genericDRParentPanel.getCancelButton().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // warn the user and reset everything
            Object[] options = { "Yes", "No" };
            int showOptionDialog = JOptionPane.showOptionDialog(null,
                    "Current analysis won't be saved. Continue?", "", JOptionPane.YES_NO_OPTION,
                    JOptionPane.WARNING_MESSAGE, null, options, options[1]);
            if (showOptionDialog == 0) {
                // reset everything
                resetOnCancel();
            }
        }
    });

    /**
     * Action listeners for shared panel. When button is selected, switch
     * view to corresponding subview
     */
    dRPanel.getInputDRButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            //switch shared table view
            updateModelInTable(dRInputController.getTableModel());
            updateTableInfoMessage("This table contains all conditions and their respective responses");
            /**
             * for (int columnIndex = 0; columnIndex <
             * dataTable.getColumnCount(); columnIndex++) {
             * GuiUtils.packColumn(dataTable, columnIndex); }
             */
            dataTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT));
            //remove other panels
            dRInitialController.getInitialChartPanel().setChart(null);
            dRNormalizedController.getNormalizedChartPanel().setChart(null);
            dRResultsController.getDupeInitialChartPanel().setChart(null);
            dRResultsController.getDupeNormalizedChartPanel().setChart(null);
            dRPanel.getGraphicsDRParentPanel().removeAll();
            dRPanel.getGraphicsDRParentPanel().revalidate();
            dRPanel.getGraphicsDRParentPanel().repaint();
            //add panel to view
            dRPanel.getGraphicsDRParentPanel().add(dRInputController.getdRInputPanel(), gridBagConstraints);
        }
    });

    dRPanel.getInitialPlotDRButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (dRAnalysisGroup != null) {
                if (isFirstFitting()) {
                    initFirstFitting();
                    setFirstFitting(false);
                }
                //switch shared table view
                updateModelInTable(dRInitialController.getTableModel());
                updateTableInfoMessage(
                        "If you checked the box at the import screen, the doses have been log-transformed. Responses have not been changed");
                /**
                 * for (int columnIndex = 0; columnIndex <
                 * dataTable.getColumnCount(); columnIndex++) {
                 * GuiUtils.packColumn(dataTable, columnIndex); }
                 */
                dataTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT));
                //remove other panels
                dRNormalizedController.getNormalizedChartPanel().setChart(null);
                dRResultsController.getDupeInitialChartPanel().setChart(null);
                dRResultsController.getDupeNormalizedChartPanel().setChart(null);
                dRPanel.getGraphicsDRParentPanel().removeAll();
                dRPanel.getGraphicsDRParentPanel().revalidate();
                dRPanel.getGraphicsDRParentPanel().repaint();
                dRPanel.getGraphicsDRParentPanel().add(dRInitialController.getDRInitialPlotPanel(),
                        gridBagConstraints);
                //Plot fitted data in dose-response curve, along with R annotation
                plotDoseResponse(dRInitialController.getInitialChartPanel(),
                        dRInitialController.getDRInitialPlotPanel().getDoseResponseChartParentPanel(),
                        getDataToFit(false), getdRAnalysisGroup(), false);
            }
        }
    });

    dRPanel.getNormalizedPlotDRButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (dRAnalysisGroup != null) {
                //in case user skips "initial" subview and goes straight to normalization
                if (isFirstFitting()) {
                    initFirstFitting();
                    setFirstFitting(false);
                }
                //switch shared table view
                updateModelInTable(dRNormalizedController.getTableModel());
                updateTableInfoMessage(
                        "Potentially log-transformed doses with their normalized responses per replicate");
                /**
                 * for (int columnIndex = 0; columnIndex <
                 * dataTable.getColumnCount(); columnIndex++) {
                 * GuiUtils.packColumn(dataTable, columnIndex); }
                 */
                dataTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT));
                //remove other panels
                dRInitialController.getInitialChartPanel().setChart(null);
                dRResultsController.getDupeInitialChartPanel().setChart(null);
                dRResultsController.getDupeNormalizedChartPanel().setChart(null);
                dRPanel.getGraphicsDRParentPanel().removeAll();
                dRPanel.getGraphicsDRParentPanel().revalidate();
                dRPanel.getGraphicsDRParentPanel().repaint();
                dRPanel.getGraphicsDRParentPanel().add(dRNormalizedController.getDRNormalizedPlotPanel(),
                        gridBagConstraints);
                //Plot fitted data in dose-response curve, along with R annotation
                plotDoseResponse(dRNormalizedController.getNormalizedChartPanel(),
                        dRNormalizedController.getDRNormalizedPlotPanel().getDoseResponseChartParentPanel(),
                        getDataToFit(true), getdRAnalysisGroup(), true);
            }
        }
    });

    dRPanel.getResultsDRButton().addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (dRAnalysisGroup != null) {
                //switch shared table view: create and set new table model with most recent statistical values
                // (these values get recalculated after each new fitting)
                dRResultsController.setTableModel(dRResultsController.reCreateTableModel(dRAnalysisGroup));
                updateModelInTable(dRResultsController.getTableModel());
                updateTableInfoMessage(
                        "Statistical values from the curve fit of the initial and normalized data.");

                //remove other panels
                dRInitialController.getInitialChartPanel().setChart(null);
                dRNormalizedController.getNormalizedChartPanel().setChart(null);
                dRPanel.getGraphicsDRParentPanel().removeAll();
                dRPanel.getGraphicsDRParentPanel().revalidate();
                dRPanel.getGraphicsDRParentPanel().repaint();
                dRPanel.getGraphicsDRParentPanel().add(dRResultsController.getdRResultsPanel(),
                        gridBagConstraints);
                //plot curves
                dRResultsController.plotCharts();
            }
        }
    });

    //add views to parent panels
    cellMissyController.getCellMissyFrame().getDoseResponseAnalysisParentPanel().add(genericDRParentPanel,
            gridBagConstraints);
    genericDRParentPanel.getDataLoadingPanel().add(loadGenericDRDataController.getDataLoadingPanel(),
            gridBagConstraints);
    genericDRParentPanel.getDoseResponseParentPanel().add(dRPanel, gridBagConstraints);
}

From source file:de.codesourcery.eve.skills.ui.components.impl.BlueprintBrowserComponent.java

@Override
protected JPanel createPanel() {

    popupMenuBuilder.addItem("Create production plan...", new AbstractAction() {
        @Override/*from  w  w  w  .  j  av  a2 s  . c o  m*/
        public boolean isEnabled() {
            return blueprintChooser.getCurrentlySelectedBlueprint() != null;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            final Blueprint blueprint = blueprintChooser.getCurrentlySelectedBlueprint();
            if (blueprint != null) {
                doubleClicked(blueprint);
            }
        }
    });

    // add text fields
    final JPanel textFields = new JPanel();
    textFields.setLayout(new GridBagLayout());

    selectedME.setColumns(5);
    selectedPE.setColumns(5);
    quantity.setColumns(6);

    selectedME.setHorizontalAlignment(JTextField.RIGHT);
    selectedPE.setHorizontalAlignment(JTextField.RIGHT);
    quantity.setHorizontalAlignment(JTextField.RIGHT);

    selectedME.addActionListener(this);
    selectedPE.addActionListener(this);
    quantity.addActionListener(this);

    textFields.add(new JLabel("ME"), constraints(0, 0).resizeBoth().end());
    textFields.add(selectedME, constraints(1, 0).weightX(0.1).anchorWest().end());

    textFields.add(new JLabel("PE"), constraints(0, 1).resizeBoth().end());

    textFields.add(selectedPE, constraints(1, 1).weightX(0.1).anchorWest().end());

    textFields.add(new JLabel("Quantity"), constraints(0, 2).resizeBoth().end());

    textFields.add(quantity, constraints(1, 2).weightX(0.1).anchorWest().end());

    // add combobox with cost calculators

    // add POS / NPC station buttons + label
    JPanel buttonPanel = new JPanel();

    final ButtonGroup group = new ButtonGroup();
    group.add(posButton);
    group.add(npcStationButton);

    posButton.addActionListener(this);
    npcStationButton.addActionListener(this);

    buttonPanel.add(posButton);
    buttonPanel.add(npcStationButton);

    textFields.add(new JLabel("Location"), constraints(0, 3).noResizing().end());
    textFields.add(buttonPanel, constraints(1, 3).useRemainingWidth().end());

    // add text area
    textArea.setEditable(false);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);

    setMonospacedFont(textArea);

    final JPanel rightPanel = new JPanel();

    rightPanel.setLayout(new GridBagLayout());
    rightPanel.add(textFields, constraints(0, 0).noResizing().end());
    rightPanel.add(new JScrollPane(textArea), constraints(0, 1).useRemainingSpace().end());

    final ImprovedSplitPane splitPane = new ImprovedSplitPane(JSplitPane.HORIZONTAL_SPLIT,
            this.blueprintChooser.createPanel(), rightPanel);

    splitPane.setDividerLocation(0.4);

    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    panel.add(splitPane, constraints(0, 0).resizeBoth().end());

    return panel;
}

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);
    toolbar.add(chartPanButton);/*  ww  w  .  ja va2s . c  om*/

    // 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;
}

From source file:edu.ucla.stat.SOCR.chart.SuperPieChart.java

public void initMapPanel() {
    listIndex = new int[dataTable.getColumnCount()];
    for (int j = 0; j < listIndex.length; j++)
        listIndex[j] = 1;//from w ww.j  ava2s . c  o  m
    bPanel = new JPanel(new BorderLayout());
    mapPanel = new JPanel(new GridLayout(2, 5, 50, 50));
    bPanel.add(mapPanel, BorderLayout.CENTER);
    //   bPanel.add(new JPanel(),BorderLayout.NORTH);

    addButton1.addActionListener(this);
    addButton2.addActionListener(this);
    addButton3.addActionListener(this);
    removeButton1.addActionListener(this);
    removeButton2.addActionListener(this);
    removeButton3.addActionListener(this);

    lModelAdded = new DefaultListModel();
    lModelDep = new DefaultListModel();
    lModelIndep = new DefaultListModel();
    lModelPullout = new DefaultListModel();

    int cellWidth = 10;

    listAdded = new JList(lModelAdded);
    listAdded.setSelectedIndex(0);
    listDepRemoved = new JList(lModelDep);
    listIndepRemoved = new JList(lModelIndep);
    listPulloutRemoved = new JList(lModelPullout);

    paintTable(listIndex);
    listAdded.setFixedCellWidth(cellWidth);
    listDepRemoved.setFixedCellWidth(cellWidth);
    listIndepRemoved.setFixedCellWidth(cellWidth);
    listPulloutRemoved.setFixedCellWidth(cellWidth);

    tools1 = new JToolBar(JToolBar.VERTICAL);
    tools2 = new JToolBar(JToolBar.VERTICAL);
    tools3 = new JToolBar(JToolBar.VERTICAL);

    if (mapDep) {
        tools1.add(depLabel);
        tools1.add(addButton1);
        tools1.add(removeButton1);
    }
    if (mapIndep) {
        tools2.add(indLabel);
        tools2.add(addButton2);
        tools2.add(removeButton2);
    }
    if (mapPullout) {
        tools3.add(pulloutLabel);
        tools3.add(addButton3);
        tools3.add(removeButton3);
    }
    tools1.setFloatable(false);
    tools2.setFloatable(false);
    tools3.setFloatable(false);

    /*  topPanel.add(listAdded);
    topPanel.add(addButton);
    topPanel.add(listDepRemoved);
    bottomPanel.add(listIndepRemoved);
    bottomPanel.add(addButton2);
    bottomPanel.add(list4); */

    JRadioButton legendPanelOnSwitch;
    JRadioButton legendPanelOffSwitch;
    //
    JPanel choicesPanel = new JPanel();
    choicesPanel.setLayout(new BoxLayout(choicesPanel, BoxLayout.Y_AXIS));
    legendPanelOnSwitch = new JRadioButton("On");
    legendPanelOnSwitch.addActionListener(this);
    legendPanelOnSwitch.setActionCommand(LEGENDON);
    legendPanelOnSwitch.setSelected(false);
    legendPanelOn = false;

    legendPanelOffSwitch = new JRadioButton("Off");
    legendPanelOffSwitch.addActionListener(this);
    legendPanelOffSwitch.setActionCommand(LEGENDOFF);
    legendPanelOffSwitch.setSelected(true);

    ButtonGroup group = new ButtonGroup();
    group.add(legendPanelOnSwitch);
    group.add(legendPanelOffSwitch);
    choicesPanel.add(new JLabel("Turn the legend panel:"));
    choicesPanel.add(legendPanelOnSwitch);
    choicesPanel.add(legendPanelOffSwitch);
    choicesPanel.setPreferredSize(new Dimension(200, 100));

    JRadioButton rotateOnSwitch;
    JRadioButton rotateOffSwitch;
    //
    JPanel rotateChoicesPanel = new JPanel();
    rotateChoicesPanel.setLayout(new BoxLayout(rotateChoicesPanel, BoxLayout.Y_AXIS));
    rotateOnSwitch = new JRadioButton("On");
    rotateOnSwitch.addActionListener(this);
    rotateOnSwitch.setActionCommand(ROTATEON);
    rotateOnSwitch.setSelected(false);
    rotateOn = false;

    rotateOffSwitch = new JRadioButton("Off");
    rotateOffSwitch.addActionListener(this);
    rotateOffSwitch.setActionCommand(ROTATEOFF);
    rotateOffSwitch.setSelected(true);

    ButtonGroup group2 = new ButtonGroup();
    group2.add(rotateOnSwitch);
    group2.add(rotateOffSwitch);
    choicesPanel.add(new JLabel("Turn the rotator:"));
    choicesPanel.add(rotateOnSwitch);
    choicesPanel.add(rotateOffSwitch);
    choicesPanel.setPreferredSize(new Dimension(200, 100));

    JPanel emptyPanel = new JPanel();
    JPanel emptyPanel2 = new JPanel();
    JPanel emptyPanel3 = new JPanel();

    //2X5
    //first line
    mapPanel.add(new JScrollPane(listAdded));
    mapPanel.add(tools1);
    mapPanel.add(new JScrollPane(listDepRemoved));

    mapPanel.add(tools3);
    if (mapPullout)
        mapPanel.add(new JScrollPane(listPulloutRemoved));
    else
        mapPanel.add(emptyPanel);
    //second line--               
    mapPanel.add(choicesPanel);
    mapPanel.add(tools2);
    mapPanel.add(new JScrollPane(listIndepRemoved));

    mapPanel.add(emptyPanel2);
    mapPanel.add(emptyPanel3);
}

From source file:net.pandoragames.far.ui.swing.RenameFilesPanel.java

private void init(SwingConfig config, ComponentRepository componentRepository) {

    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    this.setBorder(
            BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING));

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));
    JLabel patternLabel = new JLabel(localizer.localize("label.find-pattern"));
    this.add(patternLabel);
    filenamePattern = new JTextField();
    filenamePattern.setPreferredSize(/*w  ww .  j  a v a2 s. c  om*/
            new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight()));
    filenamePattern
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));
    filenamePattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    UndoHistory findUndoManager = new UndoHistory();
    findUndoManager.registerUndoHistory(filenamePattern);
    findUndoManager.registerSnapshotHistory(filenamePattern);
    componentRepository.getReplaceCommand().addResetable(findUndoManager);
    filenamePattern.getDocument().addDocumentListener(new DocumentChangeListener() {
        public void documentUpdated(DocumentEvent e, String text) {
            dataModel.setPatternString(text);
            updateFileTable();
        }
    });
    componentRepository.getResetDispatcher().addToBeCleared(filenamePattern);
    this.add(filenamePattern);
    JCheckBox caseBox = new JCheckBox(localizer.localize("label.ignore-case"));
    caseBox.setSelected(true);
    caseBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setIgnoreCase((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(caseBox);
    JCheckBox regexBox = new JCheckBox(localizer.localize("label.regular-expression"));
    regexBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setRegexPattern((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(regexBox);
    JPanel extensionPanel = new JPanel();
    extensionPanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-extension")));
    extensionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    extensionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    extensionPanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 60));
    extensionPanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 100));
    ButtonGroup extensionGroup = new ButtonGroup();
    JRadioButton protectButton = new JRadioButton(localizer.localize("label.protect-extension"));
    protectButton.setSelected(true);
    protectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setProtectExtension(true);
            updateFileTable();
        }
    });
    extensionGroup.add(protectButton);
    extensionPanel.add(protectButton);
    JRadioButton includeButton = new JRadioButton(localizer.localize("label.include-extension"));
    includeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setExtensionOnly(false);
            dataModel.setProtectExtension(false);
            updateFileTable();
        }
    });
    extensionGroup.add(includeButton);
    extensionPanel.add(includeButton);
    JRadioButton onlyButton = new JRadioButton(localizer.localize("label.only-extension"));
    onlyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setExtensionOnly(true);
            updateFileTable();
        }
    });
    extensionGroup.add(onlyButton);
    extensionPanel.add(onlyButton);
    this.add(extensionPanel);

    this.add(Box.createVerticalGlue());
    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    // replace
    JLabel replaceLabel = new JLabel(localizer.localize("label.replacement-pattern"));
    this.add(replaceLabel);
    replacePattern = new JTextField();
    replacePattern.setPreferredSize(
            new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight()));
    replacePattern
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));
    replacePattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    UndoHistory undoManager = new UndoHistory();
    undoManager.registerUndoHistory(replacePattern);
    undoManager.registerSnapshotHistory(replacePattern);
    componentRepository.getReplaceCommand().addResetable(undoManager);
    replacePattern.getDocument().addDocumentListener(new DocumentChangeListener() {
        public void documentUpdated(DocumentEvent e, String text) {
            dataModel.setReplacementString(text);
            updateFileTable();
        }
    });
    componentRepository.getResetDispatcher().addToBeCleared(replacePattern);
    this.add(replacePattern);

    // treat case
    JPanel modifyCasePanel = new JPanel();
    modifyCasePanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-case")));
    modifyCasePanel.setLayout(new BoxLayout(modifyCasePanel, BoxLayout.Y_AXIS));
    modifyCasePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    modifyCasePanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 100));
    modifyCasePanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 200));
    ButtonGroup modifyCaseGroup = new ButtonGroup();
    ActionListener radioButtonListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String cmd = e.getActionCommand();
            dataModel.setTreatCase(RenameForm.CASEHANDLING.valueOf(cmd));
            updateFileTable();
        }
    };
    JRadioButton lowerButton = new JRadioButton(localizer.localize("label.to-lower-case"));
    lowerButton.setActionCommand(RenameForm.CASEHANDLING.LOWER.name());
    lowerButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(lowerButton);
    modifyCasePanel.add(lowerButton);
    JRadioButton upperButton = new JRadioButton(localizer.localize("label.to-upper-case"));
    upperButton.setActionCommand(RenameForm.CASEHANDLING.UPPER.name());
    upperButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(upperButton);
    modifyCasePanel.add(upperButton);
    JRadioButton keepButton = new JRadioButton(localizer.localize("label.preserve-case"));
    keepButton.setActionCommand(RenameForm.CASEHANDLING.PRESERVE.name());
    keepButton.setSelected(true);
    keepButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(keepButton);
    modifyCasePanel.add(keepButton);
    this.add(modifyCasePanel);

    // prevent case conflict
    JCheckBox caseConflictBox = new JCheckBox(localizer.localize("label.prevent-case-conflict"));
    caseConflictBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    caseConflictBox.setSelected(true);
    caseConflictBox.setEnabled(!SwingConfig.isWindows()); // disabled on windows
    caseConflictBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setPreventCaseConflict((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(caseConflictBox);

    this.add(Box.createVerticalGlue());

}

From source file:JDAC.JDAC.java

public JDAC() {
    setTitle("JDAC");

    ImageIcon img = new ImageIcon("logo.png");
    setIconImage(img.getImage());//from   w  ww.j a v a  2  s .c  om

    //setLayout(new FlowLayout());

    mDataset = createDataset("A");

    mChart = ChartFactory.createXYLineChart("Preview", "Time (ms)", "Value", mDataset, PlotOrientation.VERTICAL,
            false, true, false);

    mLastChart = ChartFactory.createXYLineChart("Last n values", "Time (ms)", "Value", createLastDataset("B"),
            PlotOrientation.VERTICAL, false, true, false);
    mChart.getXYPlot().getDomainAxis().setLowerMargin(0);
    mChart.getXYPlot().getDomainAxis().setUpperMargin(0);
    mLastChart.getXYPlot().getDomainAxis().setLowerMargin(0);
    mLastChart.getXYPlot().getDomainAxis().setUpperMargin(0);

    ChartPanel chartPanel = new ChartPanel(mChart);
    ChartPanel chartLastPanel = new ChartPanel(mLastChart);
    //chartPanel.setPreferredSize( new java.awt.Dimension( 560 , 367 ) );

    XYPlot plot = mChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.GREEN);
    renderer.setSeriesStroke(0, new BasicStroke(1.0f));
    plot.setRenderer(renderer);

    XYPlot lastPlot = mLastChart.getXYPlot();
    XYLineAndShapeRenderer lastRenderer = new XYLineAndShapeRenderer();
    lastRenderer.setSeriesPaint(0, Color.RED);
    lastRenderer.setSeriesStroke(0, new BasicStroke(1.0f));
    lastPlot.setRenderer(lastRenderer);

    resetChartButton = new JButton("Reset");
    resetChartButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            resetChart();
        }
    });

    mMenuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    JMenu sensorMenu = new JMenu("Sensor");
    JMenu deviceMenu = new JMenu("Device");
    portSubMenu = new JMenu("Port");
    JMenu helpMenu = new JMenu("Help");

    serialStatusLabel = new JLabel("Disconnected");
    statusLabel = new JLabel("Ready");
    clearStatus = new LabelClear(statusLabel);
    clearStatus.resetTime();

    connectButton = new JMenuItem("Connect");
    disconnectButton = new JMenuItem("Disconnect");
    startButton = new JButton("Start");
    stopButton = new JButton("Stop");
    scanButton = new JMenuItem("Refresh port list");
    exportCSVButton = new JMenuItem("Export data to CSV");
    exportCSVButton.setAccelerator(KeyStroke.getKeyStroke("control S"));
    exportCSVButton.setMnemonic(KeyEvent.VK_S);
    exportPNGButton = new JMenuItem("Export chart to PNG");

    JPanel optionsPanel = new JPanel(new BorderLayout());

    JMenuItem exitItem = new JMenuItem("Exit");
    exitItem.setAccelerator(KeyStroke.getKeyStroke("control X"));
    exitItem.setMnemonic(KeyEvent.VK_X);

    JMenuItem aboutItem = new JMenuItem("About");
    JMenuItem helpItem = new JMenuItem("Help");
    JMenuItem quickStartItem = new JMenuItem("Quick start");

    lastSpinner = new JSpinner(new SpinnerNumberModel(10, 0, 1000, 1));

    ActionListener mSensorListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setSensor(e.getActionCommand());
        }
    };
    ButtonGroup sensorGroup = new ButtonGroup();
    JRadioButtonMenuItem tmpRadioButton = new JRadioButtonMenuItem("Temperature");
    sensorGroup.add(tmpRadioButton);
    sensorMenu.add(tmpRadioButton);
    tmpRadioButton.addActionListener(mSensorListener);
    tmpRadioButton = new JRadioButtonMenuItem("Distance");
    sensorGroup.add(tmpRadioButton);
    sensorMenu.add(tmpRadioButton);
    tmpRadioButton.addActionListener(mSensorListener);
    tmpRadioButton = new JRadioButtonMenuItem("Voltage");
    sensorGroup.add(tmpRadioButton);
    sensorMenu.add(tmpRadioButton);
    tmpRadioButton.addActionListener(mSensorListener);
    tmpRadioButton = new JRadioButtonMenuItem("Generic");
    tmpRadioButton.setSelected(true);
    setSensor("Generic");
    sensorGroup.add(tmpRadioButton);
    sensorMenu.add(tmpRadioButton);
    tmpRadioButton.addActionListener(mSensorListener);

    connectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (selectedPortName == null) {
                setStatus("No port selected");
                return;
            }
            connect(selectedPortName);
        }
    });
    disconnectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            serialStatusLabel.setText("Disconnecting...");
            if (serialPort == null) {
                serialStatusLabel.setText("Disconnected");
                serialConnected = false;
                return;
            }

            stopCollect();
            disconnect();
        }
    });
    scanButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            searchForPorts();
        }
    });
    exportCSVButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            saveData();
        }
    });
    exportPNGButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            exportPNG();
        }
    });
    startButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            startCollect();
        }
    });
    stopButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            stopCollect();
        }
    });
    lastSpinner.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            numLastValues = (Integer) lastSpinner.getValue();
            updateLastTitle();
        }
    });
    updateLastTitle();
    exitItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    helpItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            new HelpFrame();
        }
    });
    aboutItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            new AboutFrame();
        }
    });
    quickStartItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            new StartFrame();
        }
    });

    fileMenu.add(exportCSVButton);
    fileMenu.add(exportPNGButton);
    fileMenu.addSeparator();
    fileMenu.add(exitItem);
    deviceMenu.add(connectButton);
    deviceMenu.add(disconnectButton);
    deviceMenu.addSeparator();
    deviceMenu.add(portSubMenu);
    deviceMenu.add(scanButton);
    helpMenu.add(quickStartItem);
    helpMenu.add(helpItem);
    helpMenu.add(aboutItem);

    mMenuBar.add(fileMenu);
    mMenuBar.add(sensorMenu);
    mMenuBar.add(deviceMenu);
    mMenuBar.add(helpMenu);

    JPanel controlsPanel = new JPanel();
    controlsPanel.add(startButton);
    controlsPanel.add(stopButton);
    controlsPanel.add(resetChartButton);
    optionsPanel.add(controlsPanel, BorderLayout.LINE_START);

    JPanel lastPanel = new JPanel(new FlowLayout());
    lastPanel.add(new JLabel("Shown values: "));
    lastPanel.add(lastSpinner);
    optionsPanel.add(lastPanel);

    JPanel serialPanel = new JPanel(new FlowLayout());
    serialPanel.add(serialStatusLabel);
    optionsPanel.add(serialPanel, BorderLayout.LINE_END);

    add(optionsPanel, BorderLayout.PAGE_START);

    JPanel mainPanel = new JPanel(new GridLayout(0, 2));
    mainPanel.add(chartPanel);
    mainPanel.add(chartLastPanel);
    add(mainPanel);

    add(statusLabel, BorderLayout.PAGE_END);
    setJMenuBar(mMenuBar);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            dispose();
        }
    });

    setSize(800, 800);
    pack();
    new StartFrame();

    //center on screen
    Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (int) ((dimension.getWidth() - getWidth()) / 2);
    int y = (int) ((dimension.getHeight() - getHeight()) / 2);
    setLocation(x, y);

    setVisible(true);
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.AnnotationReportApplet.java

private JMenu createViewMenu() {
    GraphicOptions view_opt = theCanvas.getWorkspace().getGraphicOptions();

    JMenu view_menu = new JMenu("View");
    view_menu.setMnemonic(KeyEvent.VK_V);

    // zoom //from  w  w  w  . j a  v a 2  s . c om
    view_menu.add(theActionManager.get("zoomnone"));
    view_menu.add(theActionManager.get("zoomin"));
    view_menu.add(theActionManager.get("zoomout"));

    view_menu.addSeparator();

    // notation 
    JRadioButtonMenuItem last = null;
    ButtonGroup groupn = new ButtonGroup();

    view_menu.add(
            last = new JRadioButtonMenuItem(theActionManager.get("notation=" + GraphicOptions.NOTATION_CFG)));
    last.setSelected(view_opt.NOTATION.equals(GraphicOptions.NOTATION_CFG));
    groupn.add(last);

    view_menu.add(
            last = new JRadioButtonMenuItem(theActionManager.get("notation=" + GraphicOptions.NOTATION_CFGBW)));
    last.setSelected(view_opt.NOTATION.equals(GraphicOptions.NOTATION_CFGBW));
    groupn.add(last);

    view_menu.add(last = new JRadioButtonMenuItem(
            theActionManager.get("notation=" + GraphicOptions.NOTATION_CFGLINK)));
    last.setSelected(view_opt.NOTATION.equals(GraphicOptions.NOTATION_CFGLINK));
    groupn.add(last);

    view_menu.add(
            last = new JRadioButtonMenuItem(theActionManager.get("notation=" + GraphicOptions.NOTATION_UOXF)));
    last.setSelected(view_opt.NOTATION.equals(GraphicOptions.NOTATION_UOXF));
    groupn.add(last);

    view_menu.add(
            last = new JRadioButtonMenuItem(theActionManager.get("notation=" + GraphicOptions.NOTATION_TEXT)));
    last.setSelected(view_opt.NOTATION.equals(GraphicOptions.NOTATION_TEXT));
    groupn.add(last);

    view_menu.addSeparator();

    // display 

    display_button_group = new ButtonGroup();
    display_models = new HashMap<String, ButtonModel>();

    view_menu.add(
            last = new JRadioButtonMenuItem(theActionManager.get("display=" + GraphicOptions.DISPLAY_COMPACT)));
    last.setSelected(view_opt.DISPLAY.equals(GraphicOptions.DISPLAY_COMPACT));
    display_models.put(GraphicOptions.DISPLAY_COMPACT, last.getModel());
    display_button_group.add(last);

    view_menu.add(
            last = new JRadioButtonMenuItem(theActionManager.get("display=" + GraphicOptions.DISPLAY_NORMAL)));
    last.setSelected(view_opt.DISPLAY.equals(GraphicOptions.DISPLAY_NORMAL));
    display_models.put(GraphicOptions.DISPLAY_NORMAL, last.getModel());
    display_button_group.add(last);

    view_menu.add(last = new JRadioButtonMenuItem(
            theActionManager.get("display=" + GraphicOptions.DISPLAY_NORMALINFO)));
    last.setSelected(view_opt.DISPLAY.equals(GraphicOptions.DISPLAY_NORMALINFO));
    display_models.put(GraphicOptions.DISPLAY_NORMALINFO, last.getModel());
    display_button_group.add(last);

    view_menu.add(
            last = new JRadioButtonMenuItem(theActionManager.get("display=" + GraphicOptions.DISPLAY_CUSTOM)));
    last.setSelected(view_opt.DISPLAY.equals(GraphicOptions.DISPLAY_CUSTOM));
    display_models.put(GraphicOptions.DISPLAY_CUSTOM, last.getModel());
    display_button_group.add(last);

    //view_menu.add( lastcb = new JCheckBoxMenuItem(theActionManager.get("showinfo")) );
    //lastcb.setState(view_opt.SHOW_INFO);

    view_menu.addSeparator();

    // orientation

    view_menu.add(theActionManager.get("orientation"));

    view_menu.addSeparator();

    view_menu.add(theActionManager.get("displaysettings"));
    view_menu.add(theActionManager.get("reportsettings"));

    return view_menu;
}