Search in sources :

Example 21 with ButtonGroup

use of javax.swing.ButtonGroup in project jabref by JabRef.

the class OpenOfficePanel method showSettingsPopup.

private void showSettingsPopup() {
    JPopupMenu menu = new JPopupMenu();
    final JCheckBoxMenuItem autoSync = new JCheckBoxMenuItem(Localization.lang("Automatically sync bibliography when inserting citations"), preferences.syncWhenCiting());
    final JRadioButtonMenuItem useActiveBase = new JRadioButtonMenuItem(Localization.lang("Look up BibTeX entries in the active tab only"));
    final JRadioButtonMenuItem useAllBases = new JRadioButtonMenuItem(Localization.lang("Look up BibTeX entries in all open libraries"));
    final JMenuItem clearConnectionSettings = new JMenuItem(Localization.lang("Clear connection settings"));
    ButtonGroup bg = new ButtonGroup();
    bg.add(useActiveBase);
    bg.add(useAllBases);
    if (preferences.useAllDatabases()) {
        useAllBases.setSelected(true);
    } else {
        useActiveBase.setSelected(true);
    }
    autoSync.addActionListener(e -> preferences.setSyncWhenCiting(autoSync.isSelected()));
    useAllBases.addActionListener(e -> preferences.setUseAllDatabases(useAllBases.isSelected()));
    useActiveBase.addActionListener(e -> preferences.setUseAllDatabases(!useActiveBase.isSelected()));
    clearConnectionSettings.addActionListener(e -> frame.output(preferences.clearConnectionSettings()));
    menu.add(autoSync);
    menu.addSeparator();
    menu.add(useActiveBase);
    menu.add(useAllBases);
    menu.addSeparator();
    menu.add(clearConnectionSettings);
    menu.show(settingsB, 0, settingsB.getHeight());
}
Also used : ButtonGroup(javax.swing.ButtonGroup) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JMenuItem(javax.swing.JMenuItem) JPopupMenu(javax.swing.JPopupMenu) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Example 22 with ButtonGroup

use of javax.swing.ButtonGroup in project jabref by JabRef.

the class BibtexKeyPatternPrefTab method appendKeyGeneratorSettings.

private void appendKeyGeneratorSettings() {
    ButtonGroup bg = new ButtonGroup();
    bg.add(letterStartA);
    bg.add(letterStartB);
    bg.add(alwaysAddLetter);
    // Build a panel for checkbox settings:
    FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 8dlu, left:pref", "");
    JPanel pan = new JPanel();
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    builder.appendSeparator(Localization.lang("Key generator settings"));
    builder.nextLine();
    builder.append(pan);
    builder.append(autoGenerateOnImport);
    builder.append(letterStartA);
    builder.nextLine();
    builder.append(pan);
    builder.append(warnBeforeOverwriting);
    builder.append(letterStartB);
    builder.nextLine();
    builder.append(pan);
    builder.append(dontOverwrite);
    builder.append(alwaysAddLetter);
    builder.nextLine();
    builder.append(pan);
    builder.append(generateOnSave);
    builder.nextLine();
    builder.append(pan);
    builder.append(Localization.lang("Replace (regular expression)") + ':');
    builder.append(Localization.lang("by") + ':');
    builder.nextLine();
    builder.append(pan);
    builder.append(keyPatternRegex);
    builder.append(keyPatternReplacement);
    builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    con.gridx = 1;
    con.gridy = 3;
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.weightx = 1;
    con.fill = GridBagConstraints.BOTH;
    gbl.setConstraints(builder.getPanel(), con);
    add(builder.getPanel());
    dontOverwrite.addChangeListener(e -> warnBeforeOverwriting.setEnabled(!dontOverwrite.isSelected()));
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) JPanel(javax.swing.JPanel) ButtonGroup(javax.swing.ButtonGroup) DefaultFormBuilder(com.jgoodies.forms.builder.DefaultFormBuilder)

Example 23 with ButtonGroup

use of javax.swing.ButtonGroup in project jabref by JabRef.

the class BasicAction method setUpFieldListPanel.

private JPanel setUpFieldListPanel() {
    JPanel inputPanel = new JPanel();
    // Panel Layout
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints con = new GridBagConstraints();
    con.weightx = 0;
    con.insets = new Insets(5, 5, 0, 5);
    con.fill = GridBagConstraints.HORIZONTAL;
    inputPanel.setLayout(gbl);
    // Border
    TitledBorder titledBorder1 = new TitledBorder(BorderFactory.createLineBorder(new Color(153, 153, 153), 2), Localization.lang("Work options"));
    inputPanel.setBorder(titledBorder1);
    inputPanel.setMinimumSize(new Dimension(10, 10));
    JScrollPane fieldScroller = new JScrollPane(fieldList);
    fieldScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    // insert buttons
    insertButton.addActionListener(event -> insertTextForTag(override.isSelected()));
    // Radio buttons
    append.setToolTipText(Localization.lang("Append the selected text to BibTeX field"));
    append.setMnemonic(KeyEvent.VK_A);
    append.setSelected(true);
    override.setToolTipText(Localization.lang("Override the BibTeX field by the selected text"));
    override.setMnemonic(KeyEvent.VK_O);
    override.setSelected(false);
    //Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    group.add(append);
    group.add(override);
    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(append);
    radioPanel.add(override);
    // insert sub components
    JLabel label1 = new JLabel(Localization.lang("Available BibTeX fields"));
    con.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(label1, con);
    inputPanel.add(label1);
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.gridheight = 8;
    con.weighty = 1;
    con.fill = GridBagConstraints.BOTH;
    gbl.setConstraints(fieldScroller, con);
    inputPanel.add(fieldScroller);
    con.fill = GridBagConstraints.HORIZONTAL;
    con.weighty = 0;
    con.gridwidth = 2;
    gbl.setConstraints(radioPanel, con);
    inputPanel.add(radioPanel);
    con.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(insertButton, con);
    inputPanel.add(insertButton);
    return inputPanel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridLayout(java.awt.GridLayout) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ButtonGroup(javax.swing.ButtonGroup) Color(java.awt.Color) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) TitledBorder(javax.swing.border.TitledBorder)

Example 24 with ButtonGroup

use of javax.swing.ButtonGroup in project JMRI by JMRI.

the class JMenuUtil method createMenuGroupFromElement.

@Nonnull
static JMenu createMenuGroupFromElement(@CheckForNull Element main, WindowInterface wi, Object context) {
    String name = "<none>";
    if (main == null) {
        log.warn("Menu from element called without an element");
        return new JMenu(name);
    }
    name = LocaleSelector.getAttribute(main, "name");
    //Next statement left in if the xml file hasn't been converted
    if ((name == null) || (name.equals(""))) {
        if (main.getChild("name") != null) {
            name = main.getChild("name").getText();
        }
    }
    JMenu menu = new JMenu(name);
    ButtonGroup group = new ButtonGroup();
    for (Object item : main.getChildren("node")) {
        Element elem = (Element) item;
        Action act = actionFromNode(elem, wi, context);
        JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(act);
        group.add(menuItem);
        menu.add(menuItem);
        if (elem.getChild("current") != null) {
            setMenuItemInterAction(context, elem.getChild("current").getText(), menuItem);
        }
    }
    return menu;
}
Also used : Action(javax.swing.Action) ButtonGroup(javax.swing.ButtonGroup) Element(org.jdom2.Element) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JMenu(javax.swing.JMenu) Nonnull(javax.annotation.Nonnull)

Example 25 with ButtonGroup

use of javax.swing.ButtonGroup in project jabref by JabRef.

the class ExternalFileTypeEntryEditor method init.

private void init(ExternalFileType inEntry) {
    entry = inEntry;
    icon.setText(null);
    ButtonGroup bg = new ButtonGroup();
    bg.add(useDefault);
    bg.add(other);
    FormBuilder builder = FormBuilder.create();
    builder.layout(new FormLayout("left:pref, 4dlu, fill:150dlu, 4dlu, fill:pref", "p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p"));
    builder.add(Localization.lang("Icon")).xy(1, 1);
    builder.add(icon).xy(3, 1);
    builder.add(Localization.lang("Name")).xy(1, 3);
    builder.add(name).xy(3, 3);
    builder.add(Localization.lang("Extension")).xy(1, 5);
    builder.add(extension).xy(3, 5);
    builder.add(Localization.lang("MIME type")).xy(1, 7);
    builder.add(mimeType).xy(3, 7);
    builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    builder.add(Localization.lang("Application")).xy(1, 9);
    JButton browseBut = new JButton(Localization.lang("Browse"));
    if (OS.WINDOWS) {
        builder.add(useDefault).xy(3, 9);
        builder.appendRows("2dlu, p");
        JPanel p1 = new JPanel();
        builder.add(p1).xy(1, 11);
        JPanel p2 = new JPanel();
        application.setPreferredSize(new Dimension(300, application.getPreferredSize().height));
        BorderLayout bl = new BorderLayout();
        bl.setHgap(4);
        p2.setLayout(bl);
        p2.add(other, BorderLayout.WEST);
        p2.add(application, BorderLayout.CENTER);
        builder.add(p2).xy(3, 11);
        builder.add(browseBut).xy(5, 11);
    } else {
        builder.add(application).xy(3, 9);
        builder.add(browseBut).xy(5, 9);
    }
    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();
    ok.addActionListener(e -> {
        okPressed = true;
        storeSettings(ExternalFileTypeEntryEditor.this.entry);
        diag.dispose();
    });
    cancel.addActionListener(e -> diag.dispose());
    if (OS.WINDOWS) {
        application.getDocument().addDocumentListener(new DocumentListener() {

            private void handle() {
                if (application.getText().isEmpty()) {
                    useDefault.setSelected(true);
                } else {
                    other.setSelected(true);
                }
            }

            @Override
            public void insertUpdate(DocumentEvent documentEvent) {
                handle();
            }

            @Override
            public void removeUpdate(DocumentEvent documentEvent) {
                handle();
            }

            @Override
            public void changedUpdate(DocumentEvent documentEvent) {
                handle();
            }
        });
    }
    String title = editFileTitle;
    if (entry.getName().isEmpty()) {
        title = newFileTitle;
    }
    if (dParent == null) {
        diag = new JDialog(fParent, title, true);
    } else {
        diag = new JDialog(dParent, title, true);
    }
    diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
    diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
    diag.pack();
    browseBut.addActionListener(browsePressed);
    if (dParent == null) {
        diag.setLocationRelativeTo(fParent);
    } else {
        diag.setLocationRelativeTo(dParent);
    }
    setValues(entry);
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) FormBuilder(com.jgoodies.forms.builder.FormBuilder) JPanel(javax.swing.JPanel) DocumentListener(javax.swing.event.DocumentListener) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) DocumentEvent(javax.swing.event.DocumentEvent) BorderLayout(java.awt.BorderLayout) ButtonGroup(javax.swing.ButtonGroup) ButtonBarBuilder(com.jgoodies.forms.builder.ButtonBarBuilder) JDialog(javax.swing.JDialog)

Aggregations

ButtonGroup (javax.swing.ButtonGroup)339 JPanel (javax.swing.JPanel)202 JRadioButton (javax.swing.JRadioButton)186 JLabel (javax.swing.JLabel)148 ActionEvent (java.awt.event.ActionEvent)134 ActionListener (java.awt.event.ActionListener)118 BoxLayout (javax.swing.BoxLayout)83 GridBagLayout (java.awt.GridBagLayout)81 JButton (javax.swing.JButton)75 JTextField (javax.swing.JTextField)70 JMenu (javax.swing.JMenu)69 GridBagConstraints (java.awt.GridBagConstraints)67 BorderLayout (java.awt.BorderLayout)64 Insets (java.awt.Insets)64 Dimension (java.awt.Dimension)58 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)57 FlowLayout (java.awt.FlowLayout)53 JMenuItem (javax.swing.JMenuItem)50 JCheckBox (javax.swing.JCheckBox)47 JScrollPane (javax.swing.JScrollPane)47