Example usage for javax.swing JRadioButton JRadioButton

List of usage examples for javax.swing JRadioButton JRadioButton

Introduction

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

Prototype

public JRadioButton(String text) 

Source Link

Document

Creates an unselected radio button with the specified text.

Usage

From source file:e3fraud.gui.MainWindow.java

public MainWindow() {
    super(new BorderLayout(5, 5));

    extended = false;//from   w w  w.j ava2s.c o  m

    //Create the log first, because the action listeners
    //need to refer to it.
    log = new JTextArea(10, 50);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setEditable(false);
    logScrollPane = new JScrollPane(log);
    DefaultCaret caret = (DefaultCaret) log.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    //        create the progress bar
    progressBar = new JProgressBar(0, 100);
    progressBar.setValue(progressBar.getMinimum());
    progressBar.setVisible(false);
    progressBar.setStringPainted(true);
    //Create the settings pane
    generationSettingLabel = new JLabel("Generate:");
    SpinnerModel collusionsSpinnerModel = new SpinnerNumberModel(1, 0, 3, 1);
    collusionSettingsPanel = new JPanel(new FlowLayout()) {
        @Override
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    // collusionSettingsPanel.setLayout(new BoxLayout(collusionSettingsPanel, BoxLayout.X_AXIS));
    collusionsButton = new JSpinner(collusionsSpinnerModel);
    collusionsLabel = new JLabel("collusion(s)");
    collusionSettingsPanel.add(collusionsButton);
    collusionSettingsPanel.add(collusionsLabel);

    rankingSettingLabel = new JLabel("Rank by:");
    lossButton = new JRadioButton("loss");
    lossButton.setToolTipText("Sort sub-ideal models based on loss for Target of Assessment (high -> low)");
    gainButton = new JRadioButton("gain");
    gainButton.setToolTipText(
            "Sort sub-ideal models based on gain of any actor except Target of Assessment (high -> low)");
    lossGainButton = new JRadioButton("loss + gain");
    lossGainButton.setToolTipText(
            "Sort sub-ideal models based on loss for Target of Assessment and, if equal, on gain of any actor except Target of Assessment");
    //gainLossButton = new JRadioButton("gain + loss");
    lossGainButton.setSelected(true);
    rankingGroup = new ButtonGroup();
    rankingGroup.add(lossButton);
    rankingGroup.add(gainButton);
    rankingGroup.add(lossGainButton);
    //rankingGroup.add(gainLossButton);
    groupingSettingLabel = new JLabel("Group by:");
    groupingButton = new JCheckBox("collusion");
    groupingButton.setToolTipText(
            "Groups sub-ideal models based on the pair of actors colluding before ranking them");
    groupingButton.setSelected(false);
    refreshButton = new JButton("Refresh");
    refreshButton.addActionListener(this);

    settingsPanel = new JPanel();
    settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS));
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(generationSettingLabel);
    collusionSettingsPanel.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(collusionSettingsPanel);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    rankingSettingLabel.setAlignmentY(TOP_ALIGNMENT);
    settingsPanel.add(rankingSettingLabel);
    settingsPanel.add(lossButton);
    settingsPanel.add(gainButton);
    settingsPanel.add(lossGainButton);
    //settingsPanel.add(gainLossButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(groupingSettingLabel);
    settingsPanel.add(groupingButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(refreshButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 20)));
    progressBar.setPreferredSize(
            new Dimension(settingsPanel.getSize().width, progressBar.getPreferredSize().height));
    settingsPanel.add(progressBar);

    //Create the result tree
    root = new DefaultMutableTreeNode("No models to display");
    treeModel = new DefaultTreeModel(root);
    tree = new JTree(treeModel);
    //tree.setUI(new CustomTreeUI());
    tree.setCellRenderer(new CustomTreeCellRenderer(tree));
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setLargeModel(true);
    resultScrollPane = new JScrollPane(tree);
    tree.addTreeSelectionListener(treeSelectionListener);

    //tree.setShowsRootHandles(true);
    //Create a file chooser for saving
    sfc = new JFileChooser();
    FileFilter jpegFilter = new FileNameExtensionFilter("JPEG image", new String[] { "jpg", "jpeg" });
    sfc.addChoosableFileFilter(jpegFilter);
    sfc.setFileFilter(jpegFilter);

    //Create a file chooser for loading
    fc = new JFileChooser();
    FileFilter rdfFilter = new FileNameExtensionFilter("RDF file", "RDF");
    fc.addChoosableFileFilter(rdfFilter);
    fc.setFileFilter(rdfFilter);

    //Create the open button.  
    openButton = new JButton("Load model", createImageIcon("images/Open24.png"));
    openButton.addActionListener(this);
    openButton.setToolTipText("Load a e3value model");

    //Create the ideal graph button. 
    idealGraphButton = new JButton("Show ideal graph", createImageIcon("images/Plot.png"));
    idealGraphButton.setToolTipText("Display ideal profitability graph");
    idealGraphButton.addActionListener(this);

    Dimension thinButtonDimension = new Dimension(15, 420);

    //Create the expand subideal graph button. 
    expandButton = new JButton(">");
    expandButton.setPreferredSize(thinButtonDimension);
    expandButton.setMargin(new Insets(0, 0, 0, 0));
    expandButton.setToolTipText("Expand to show non-ideal profitability graph for selected model");
    expandButton.addActionListener(this);

    //Create the collapse sub-ideal graph button. 
    collapseButton = new JButton("<");
    collapseButton.setPreferredSize(thinButtonDimension);
    collapseButton.setMargin(new Insets(0, 0, 0, 0));
    collapseButton.setToolTipText("Collapse non-ideal profitability graph for selected model");
    collapseButton.addActionListener(this);

    //Create the generation button. 
    generateButton = new JButton("Generate sub-ideal models", createImageIcon("images/generate.png"));
    generateButton.addActionListener(this);
    generateButton.setToolTipText("Generate sub-ideal models for the e3value model currently loaded");

    //Create the chart panel
    chartPane = new JPanel();
    chartPane.setLayout(new FlowLayout(FlowLayout.LEFT));
    chartPane.add(expandButton);

    //For layout purposes, put the buttons in a separate panel
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(openButton);
    buttonPanel.add(Box.createRigidArea(new Dimension(20, 0)));
    buttonPanel.add(generateButton);
    buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonPanel.add(idealGraphButton);

    //Add the buttons, the ranking options, the result list and the log to this panel.
    add(buttonPanel, BorderLayout.PAGE_START);
    add(settingsPanel, BorderLayout.LINE_START);
    add(resultScrollPane, BorderLayout.CENTER);

    add(logScrollPane, BorderLayout.PAGE_END);
    add(chartPane, BorderLayout.LINE_END);
    //and make a nice border around it
    setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10));
}

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);/*  w  w  w.ja  v  a  2  s.c om*/

    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// w w  w .ja v  a  2 s  .  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.emental.mindraider.ui.dialogs.AttachmentJDialog.java

/**
 * Concetructor./*w w w  .  j  a  v  a2s  . c om*/
 * 
 * @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:net.lmxm.ute.gui.editors.tasks.SubversionExportTaskEditorPanel.java

/**
 * Gets the date revision radio button.//w w  w.  j  a  v a2  s  . co  m
 * 
 * @return the date revision radio button
 */
private JRadioButton getDateRevisionRadioButton() {
    if (dateRevisionRadioButton == null) {
        dateRevisionRadioButton = new JRadioButton(SubversionRevision.DATE.toString());
        dateRevisionRadioButton.addActionListener(revisionActionListener);
    }

    return dateRevisionRadioButton;
}

From source file:com.rapidminer.gui.new_plotter.gui.dialog.AddParallelLineDialog.java

/**
 * Setup the GUI./*from ww w .j  av  a  2 s. c  o m*/
 */
private void setupGUI() {
    JPanel mainPanel = new JPanel();
    this.setContentPane(mainPanel);

    // start layout
    mainPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 2, 5);
    horizontalLineRadiobutton = new JRadioButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.horizontal.label"));
    horizontalLineRadiobutton.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.horizontal.tip"));
    horizontalLineRadiobutton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setHorizontalLineSelected();
        }
    });
    horizontalLineRadiobutton.setSelected(true);
    this.add(horizontalLineRadiobutton, gbc);

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.EAST;
    verticalLineRadiobutton = new JRadioButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.vertical.label"));
    verticalLineRadiobutton
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.vertical.tip"));
    verticalLineRadiobutton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setVerticalLineSelected();
        }
    });
    this.add(verticalLineRadiobutton, gbc);

    ButtonGroup group = new ButtonGroup();
    group.add(horizontalLineRadiobutton);
    group.add(verticalLineRadiobutton);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1;
    gbc.gridwidth = 2;
    gbc.anchor = GridBagConstraints.CENTER;
    rangeAxisSelectionCombobox = new JComboBox();
    rangeAxisSelectionCombobox.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.range_axis_combobox.tip"));
    rangeAxisSelectionCombobox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateYFieldValue();
        }
    });
    this.add(rangeAxisSelectionCombobox, gbc);

    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 2, 5);
    JLabel xLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.width.label"));
    this.add(xLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.insets = new Insets(2, 5, 2, 5);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    xField = new JTextField();
    xField.setText(String.valueOf(x));
    xField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyYInput(input);
        }
    });
    xField.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.width.tip"));
    xField.setEnabled(false);
    this.add(xField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.NONE;
    JLabel yLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.height.label"));
    this.add(yLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    yField = new JTextField();
    yField.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.height.tip"));
    yField.setText(String.valueOf(y));
    yField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyXInput(input);
        }
    });
    this.add(yField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(10, 5, 0, 5);
    modifyLineButton = new JButton();
    modifyLineButton.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.modify_line.tip"));
    modifyLineButton.setIcon(SwingTools.createIcon(
            "16/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.modify_line.icon")));
    modifyLineButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            modifyLine();
        }
    });
    this.add(modifyLineButton, gbc);

    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.gridwidth = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(15, 5, 5, 5);
    this.add(new JSeparator(), gbc);

    gbc.gridx = 0;
    gbc.gridy = 6;
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 5, 5);
    okButton = new JButton(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.label"));
    okButton.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.tip"));
    okButton.setIcon(SwingTools
            .createIcon("24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.icon")));
    okButton.setMnemonic(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.mne").toCharArray()[0]);
    okButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean successful = addSpecifiedLine();
            // don't dispose dialog if not successful
            if (!successful) {
                return;
            }

            AddParallelLineDialog.this.dispose();
        }
    });
    okButton.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                okButton.doClick();
            }
        }
    });
    this.add(okButton, gbc);

    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    cancelButton = new JButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.label"));
    cancelButton
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.tip"));
    cancelButton.setIcon(SwingTools.createIcon(
            "24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.icon")));
    cancelButton.setMnemonic(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.mne").toCharArray()[0]);
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // cancel requested, close dialog
            AddParallelLineDialog.this.dispose();
        }
    });
    this.add(cancelButton, gbc);

    // misc settings
    this.setMinimumSize(new Dimension(300, 250));
    // center dialog
    this.setLocationRelativeTo(null);
    this.setTitle(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.title.label"));
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.setModal(true);

    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowActivated(WindowEvent e) {
            okButton.requestFocusInWindow();
        }
    });
}

From source file:components.DialogDemo.java

/** Creates the panel shown by the first tab. */
private JPanel createSimpleDialogBox() {
    final int numButtons = 4;
    JRadioButton[] radioButtons = new JRadioButton[numButtons];
    final ButtonGroup group = new ButtonGroup();

    JButton showItButton = null;/*www .ja v  a 2  s.  co  m*/

    final String defaultMessageCommand = "default";
    final String yesNoCommand = "yesno";
    final String yeahNahCommand = "yeahnah";
    final String yncCommand = "ync";

    radioButtons[0] = new JRadioButton("OK (in the L&F's words)");
    radioButtons[0].setActionCommand(defaultMessageCommand);

    radioButtons[1] = new JRadioButton("Yes/No (in the L&F's words)");
    radioButtons[1].setActionCommand(yesNoCommand);

    radioButtons[2] = new JRadioButton("Yes/No " + "(in the programmer's words)");
    radioButtons[2].setActionCommand(yeahNahCommand);

    radioButtons[3] = new JRadioButton("Yes/No/Cancel " + "(in the programmer's words)");
    radioButtons[3].setActionCommand(yncCommand);

    for (int i = 0; i < numButtons; i++) {
        group.add(radioButtons[i]);
    }
    radioButtons[0].setSelected(true);

    showItButton = new JButton("Show it!");
    showItButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String command = group.getSelection().getActionCommand();

            //ok dialog
            if (command == defaultMessageCommand) {
                JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.");

                //yes/no dialog
            } else if (command == yesNoCommand) {
                int n = JOptionPane.showConfirmDialog(frame, "Would you like green eggs and ham?",
                        "An Inane Question", JOptionPane.YES_NO_OPTION);
                if (n == JOptionPane.YES_OPTION) {
                    setLabel("Ewww!");
                } else if (n == JOptionPane.NO_OPTION) {
                    setLabel("Me neither!");
                } else {
                    setLabel("Come on -- tell me!");
                }

                //yes/no (not in those words)
            } else if (command == yeahNahCommand) {
                Object[] options = { "Yes, please", "No way!" };
                int n = JOptionPane.showOptionDialog(frame, "Would you like green eggs and ham?",
                        "A Silly Question", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                        options, options[0]);
                if (n == JOptionPane.YES_OPTION) {
                    setLabel("You're kidding!");
                } else if (n == JOptionPane.NO_OPTION) {
                    setLabel("I don't like them, either.");
                } else {
                    setLabel("Come on -- 'fess up!");
                }

                //yes/no/cancel (not in those words)
            } else if (command == yncCommand) {
                Object[] options = { "Yes, please", "No, thanks", "No eggs, no ham!" };
                int n = JOptionPane.showOptionDialog(frame,
                        "Would you like some green eggs to go " + "with that ham?", "A Silly Question",
                        JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options,
                        options[2]);
                if (n == JOptionPane.YES_OPTION) {
                    setLabel("Here you go: green eggs and ham!");
                } else if (n == JOptionPane.NO_OPTION) {
                    setLabel("OK, just the ham, then.");
                } else if (n == JOptionPane.CANCEL_OPTION) {
                    setLabel("Well, I'm certainly not going to eat them!");
                } else {
                    setLabel("Please tell me what you want!");
                }
            }
            return;
        }
    });

    return createPane(simpleDialogDesc + ":", radioButtons, showItButton);
}

From source file:it.iit.genomics.cru.igb.bundles.mi.view.StructuresPanel.java

public StructuresPanel(IgbService service, String label) {

    super("MI Structures", "MI Structures", "Display structure", true);

    igbLogger = IGBLogger.getInstance(label);

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

    // Create hidden JmolFrame
    jmolFrame = new JFrame();

    jmolPanel = new JmolPanel();

    jmolPanel.setPreferredSize(new Dimension(500, 500));

    Box jmolBox = new Box(BoxLayout.Y_AXIS);
    Box jmolButtonBox = new Box(BoxLayout.X_AXIS);
    jmolFrame.add(jmolBox);/*from  w  w  w  . j  a v  a2s. co  m*/
    jmolBox.add(jmolPanel);
    jmolBox.add(jmolButtonBox);

    jmolButtonBox.add(new JLabel("Display type:"));

    ButtonGroup displayGroup = new ButtonGroup();
    JRadioButton cartoonButton = new JRadioButton(JMOL_DISPLAY_CARTOON);
    JRadioButton ballAndSticksButton = new JRadioButton(JMOL_DISPLAY_BALL_AND_STICK);

    JmolDisplayListener listener = new JmolDisplayListener();
    cartoonButton.addActionListener(listener);
    ballAndSticksButton.addActionListener(listener);

    displayGroup.add(cartoonButton);
    displayGroup.add(ballAndSticksButton);

    jmolButtonBox.add(cartoonButton);
    jmolButtonBox.add(ballAndSticksButton);

    ballAndSticksButton.setSelected(true);

    jmolFrame.pack();
    jmolFrame.setVisible(false);

    jmolButton.addActionListener(new JmolActionListener());
    jmolButton.setIcon(new ImageIcon(getClass().getResource("/jmol.jpg")));

    linkButton.addActionListener(new ExternalLinkActionListener());
    linkButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/searchweb.png"));

    StructureTableModel model = new StructureTableModel(new ArrayList<StructureItem>(0));

    structureList = new StructureTable(model, service);
    structureList.setTableHeader(null);

    structureList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane structureListPane = new JScrollPane(structureList);

    add(structureListPane);
}

From source file:com.eviware.soapui.support.editor.inspectors.auth.ExpirationTimeChooser.java

private void initializeRadioButtons() {
    long serverIssuedExpirationTime = profile.getAccessTokenExpirationTime();
    String serverIssuedExpirationTimeLabel;
    if (serverIssuedExpirationTime > 0) {
        serverIssuedExpirationTimeLabel = getMostLegibleTimeString(serverIssuedExpirationTime);
    } else {/*from   w ww.  j a  v  a2s.c  o  m*/
        serverIssuedExpirationTimeLabel = "No expiration";
    }

    serverExpirationTimeOption = new JRadioButton(
            "Use expiration time from authorization server: " + serverIssuedExpirationTimeLabel);
    serverExpirationTimeOption.setName(SERVER_EXPIRATION_RADIO_NAME);
    ActionListener checkBoxMonitor = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            timeTextField.setEnabled(manualExpirationTimeOption.isSelected());
            timeUnitCombo.setEnabled(manualExpirationTimeOption.isSelected());
        }
    };
    serverExpirationTimeOption.addActionListener(checkBoxMonitor);

    manualExpirationTimeOption = new JRadioButton("Custom");
    manualExpirationTimeOption.setName(MANUAL_EXPIRATION_RADIO_NAME);
    manualExpirationTimeOption.addActionListener(checkBoxMonitor);

    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(serverExpirationTimeOption);
    buttonGroup.add(manualExpirationTimeOption);

    if (profile.useManualAccessTokenExpirationTime()) {
        manualExpirationTimeOption.setSelected(true);
    } else {
        serverExpirationTimeOption.setSelected(true);
    }
}

From source file:au.org.ala.delta.intkey.ui.FindInTaxaDialog.java

public FindInTaxaDialog(Intkey intkeyApp) {
    super(intkeyApp.getMainFrame(), false);
    setResizable(false);//from   w w  w . jav  a 2 s  .co  m

    ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(FindInTaxaDialog.class);
    resourceMap.injectFields(this);
    ActionMap actionMap = Application.getInstance().getContext().getActionMap(this);

    _intkeyApp = intkeyApp;

    _numMatchedTaxa = 0;
    _currentMatchedTaxon = -1;

    _findAction = actionMap.get("findTaxa");
    _nextAction = actionMap.get("nextFoundTaxon");

    this.setTitle(windowTitle);

    getContentPane().setLayout(new BorderLayout(0, 0));

    _pnlMain = new JPanel();
    _pnlMain.setBorder(new EmptyBorder(20, 20, 20, 20));
    getContentPane().add(_pnlMain, BorderLayout.CENTER);
    _pnlMain.setLayout(new BorderLayout(0, 0));

    _pnlMainTop = new JPanel();
    _pnlMain.add(_pnlMainTop, BorderLayout.NORTH);
    _pnlMainTop.setLayout(new BoxLayout(_pnlMainTop, BoxLayout.Y_AXIS));

    _lblEnterSearchString = new JLabel(enterSearchStringCaption);
    _lblEnterSearchString.setBorder(new EmptyBorder(0, 0, 5, 0));
    _lblEnterSearchString.setHorizontalAlignment(SwingConstants.LEFT);
    _lblEnterSearchString.setVerticalAlignment(SwingConstants.TOP);
    _lblEnterSearchString.setAlignmentY(Component.TOP_ALIGNMENT);
    _pnlMainTop.add(_lblEnterSearchString);

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

        @Override
        public void removeUpdate(DocumentEvent e) {
            reset();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            reset();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            reset();
        }
    });

    _pnlMainTop.add(_textField);
    _textField.setColumns(10);

    _pnlMainMiddle = new JPanel();
    _pnlMainMiddle.setBorder(new EmptyBorder(10, 0, 0, 0));
    _pnlMain.add(_pnlMainMiddle, BorderLayout.CENTER);
    _pnlMainMiddle.setLayout(new BoxLayout(_pnlMainMiddle, BoxLayout.Y_AXIS));

    _rdbtnSelectOne = new JRadioButton(selectOneCaption);
    _rdbtnSelectOne.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            reset();
        }
    });
    _pnlMainMiddle.add(_rdbtnSelectOne);

    _rdbtnSelectAll = new JRadioButton(selectAllCaption);
    _rdbtnSelectAll.setSelected(true);
    _rdbtnSelectAll.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            reset();
        }
    });
    _pnlMainMiddle.add(_rdbtnSelectAll);

    ButtonGroup radioButtonGroup = new ButtonGroup();
    radioButtonGroup.add(_rdbtnSelectOne);
    radioButtonGroup.add(_rdbtnSelectAll);

    _pnlMainBottom = new JPanel();
    _pnlMain.add(_pnlMainBottom, BorderLayout.SOUTH);
    _pnlMainBottom.setLayout(new BoxLayout(_pnlMainBottom, BoxLayout.Y_AXIS));

    _chckbxSearchSynonyms = new JCheckBox(searchSynonymsCaption);
    _chckbxSearchSynonyms.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            reset();
        }
    });

    _pnlMainBottom.add(_chckbxSearchSynonyms);

    _chckbxSearchEliminatedTaxa = new JCheckBox(searchEliminatedTaxaCaption);
    _chckbxSearchEliminatedTaxa.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            reset();
        }
    });

    _pnlMainBottom.add(_chckbxSearchEliminatedTaxa);

    _pnlButtons = new JPanel();
    _pnlButtons.setBorder(new EmptyBorder(20, 0, 0, 10));
    getContentPane().add(_pnlButtons, BorderLayout.EAST);
    _pnlButtons.setLayout(new BorderLayout(0, 0));

    _pnlInnerButtons = new JPanel();
    _pnlButtons.add(_pnlInnerButtons, BorderLayout.NORTH);
    GridBagLayout gbl_pnlInnerButtons = new GridBagLayout();
    gbl_pnlInnerButtons.columnWidths = new int[] { 0, 0 };
    gbl_pnlInnerButtons.rowHeights = new int[] { 0, 0, 0, 0 };
    gbl_pnlInnerButtons.columnWeights = new double[] { 0.0, Double.MIN_VALUE };
    gbl_pnlInnerButtons.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
    _pnlInnerButtons.setLayout(gbl_pnlInnerButtons);

    _btnFindNext = new JButton();
    _btnFindNext.setAction(_findAction);
    GridBagConstraints gbc_btnFind = new GridBagConstraints();
    gbc_btnFind.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnFind.insets = new Insets(0, 0, 5, 0);
    gbc_btnFind.gridx = 0;
    gbc_btnFind.gridy = 0;
    _pnlInnerButtons.add(_btnFindNext, gbc_btnFind);

    _btnPrevious = new JButton();
    _btnPrevious.setAction(actionMap.get("previousFoundTaxon"));
    _btnPrevious.setEnabled(false);
    GridBagConstraints gbc_btnPrevious = new GridBagConstraints();
    gbc_btnPrevious.insets = new Insets(0, 0, 5, 0);
    gbc_btnPrevious.gridx = 0;
    gbc_btnPrevious.gridy = 1;
    _pnlInnerButtons.add(_btnPrevious, gbc_btnPrevious);

    _btnDone = new JButton();
    _btnDone.setAction(actionMap.get("findTaxaDone"));
    GridBagConstraints gbc_btnDone = new GridBagConstraints();
    gbc_btnDone.fill = GridBagConstraints.HORIZONTAL;
    gbc_btnDone.gridx = 0;
    gbc_btnDone.gridy = 2;
    _pnlInnerButtons.add(_btnDone, gbc_btnDone);

    this.pack();
    this.setLocationRelativeTo(_intkeyApp.getMainFrame());
}