Search in sources :

Example 61 with JRadioButtonMenuItem

use of javax.swing.JRadioButtonMenuItem 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 62 with JRadioButtonMenuItem

use of javax.swing.JRadioButtonMenuItem 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 63 with JRadioButtonMenuItem

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

the class PositionablePopupUtil method addFontMenuEntry.

void addFontMenuEntry(JMenu menu, ButtonGroup fontButtonGroup, final int size) {
    JRadioButtonMenuItem r = new JRadioButtonMenuItem("" + size);
    r.addActionListener((ActionEvent e) -> {
        setFontSize(size);
    });
    fontButtonGroup.add(r);
    if (_textComponent.getFont().getSize() == size) {
        r.setSelected(true);
    } else {
        r.setSelected(false);
    }
    menu.add(r);
}
Also used : ActionEvent(java.awt.event.ActionEvent) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem)

Example 64 with JRadioButtonMenuItem

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

the class ControlPanelEditor method makeSelectLevelMenu.

private JMenu makeSelectLevelMenu() {
    JMenu menu = new JMenu(Bundle.getMessage("SelectLevel"));
    ButtonGroup levelGroup = new ButtonGroup();
    JRadioButtonMenuItem button = null;
    for (int i = 0; i < 11; i++) {
        button = new JRadioButtonMenuItem(Bundle.getMessage("selectLevel", "" + i));
        levelGroup.add(button);
        menu.add(button);
        button.addActionListener(new ActionListener() {

            int j;

            ActionListener init(int k) {
                j = k;
                return this;
            }

            @Override
            public void actionPerformed(ActionEvent event) {
                selectLevel(j);
            }
        }.init(i));
    }
    return menu;
}
Also used : ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JMenu(javax.swing.JMenu) Point(java.awt.Point)

Example 65 with JRadioButtonMenuItem

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

the class LogixTableAction method setMenuBar.

/**
     * Insert 2 table specific menus.
     * <p>
     * Accounts for the Window and Help menus, which are already added to the menu bar
     * as part of the creation of the JFrame, by adding the new menus 2 places earlier
     * unless the table is part of the ListedTableFrame, which adds the Help menu later on.
     * @param f the JFrame of this table
     */
@Override
public void setMenuBar(BeanTableFrame f) {
    loadSelectionMode();
    JMenu menu = new JMenu(Bundle.getMessage("MenuOptions"));
    menu.setMnemonic(KeyEvent.VK_O);
    javax.swing.JMenuBar menuBar = f.getJMenuBar();
    // count the number of menus to insert the TableMenus before 'Window' and 'Help'
    int pos = menuBar.getMenuCount() - 1;
    int offset = 1;
    log.debug("setMenuBar number of menu items = " + pos);
    for (int i = 0; i <= pos; i++) {
        if (menuBar.getComponent(i) instanceof JMenu) {
            if (((JMenu) menuBar.getComponent(i)).getText().equals(Bundle.getMessage("MenuHelp"))) {
                // correct for use as part of ListedTableAction where the Help Menu is not yet present
                offset = -1;
            }
        }
    }
    ButtonGroup enableButtonGroup = new ButtonGroup();
    JRadioButtonMenuItem r = new JRadioButtonMenuItem(rbx.getString("EnableAll"));
    r.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            enableAll(true);
        }
    });
    enableButtonGroup.add(r);
    r.setSelected(true);
    menu.add(r);
    r = new JRadioButtonMenuItem(rbx.getString("DisableAll"));
    r.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            enableAll(false);
        }
    });
    enableButtonGroup.add(r);
    menu.add(r);
    menu.addSeparator();
    ButtonGroup modeButtonGroup = new ButtonGroup();
    r = new JRadioButtonMenuItem(rbx.getString("UseMultiPick"));
    r.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            setSelectionMode(SelectionMode.USEMULTI);
        }
    });
    modeButtonGroup.add(r);
    menu.add(r);
    r.setSelected(_selectionMode == SelectionMode.USEMULTI);
    r = new JRadioButtonMenuItem(rbx.getString("UseSinglePick"));
    r.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            setSelectionMode(SelectionMode.USESINGLE);
        }
    });
    modeButtonGroup.add(r);
    menu.add(r);
    r.setSelected(_selectionMode == SelectionMode.USESINGLE);
    r = new JRadioButtonMenuItem(rbx.getString("UseComboNameBoxes"));
    r.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            setSelectionMode(SelectionMode.USECOMBO);
        }
    });
    modeButtonGroup.add(r);
    menu.add(r);
    r.setSelected(_selectionMode == SelectionMode.USECOMBO);
    menuBar.add(menu, pos + offset);
    menu = new JMenu(Bundle.getMessage("MenuTools"));
    menu.setMnemonic(KeyEvent.VK_T);
    JMenuItem item = new JMenuItem(rbx.getString("OpenPickListTables"));
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            OpenPickListTable();
        }
    });
    menu.add(item);
    item = new JMenuItem(rbx.getString("FindOrphans"));
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            findOrphansPressed(e);
        }
    });
    menu.add(item);
    item = new JMenuItem(rbx.getString("EmptyConditionals"));
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            findEmptyPressed(e);
        }
    });
    menu.add(item);
    item = new JMenuItem(rbx.getString("CrossReference"));
    item.addActionListener(new ActionListener() {

        BeanTableFrame parent;

        @Override
        public void actionPerformed(ActionEvent e) {
            new RefDialog(parent);
        }

        ActionListener init(BeanTableFrame f) {
            parent = f;
            return this;
        }
    }.init(f));
    menu.add(item);
    item = new JMenuItem(rbx.getString("DisplayWhereUsed"));
    item.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            makeWhereUsedWindow();
        }
    });
    menu.add(item);
    // add this menu to the right of the previous
    menuBar.add(menu, pos + offset + 1);
}
Also used : ItemEvent(java.awt.event.ItemEvent) ActionEvent(java.awt.event.ActionEvent) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ItemListener(java.awt.event.ItemListener) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Aggregations

JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)246 ButtonGroup (javax.swing.ButtonGroup)123 JMenu (javax.swing.JMenu)110 JMenuItem (javax.swing.JMenuItem)85 ActionEvent (java.awt.event.ActionEvent)81 ActionListener (java.awt.event.ActionListener)69 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)38 JPopupMenu (javax.swing.JPopupMenu)31 JMenuBar (javax.swing.JMenuBar)21 ItemEvent (java.awt.event.ItemEvent)19 ItemListener (java.awt.event.ItemListener)19 JPanel (javax.swing.JPanel)19 AbstractAction (javax.swing.AbstractAction)18 JSeparator (javax.swing.JSeparator)15 JButton (javax.swing.JButton)12 JLabel (javax.swing.JLabel)12 BorderLayout (java.awt.BorderLayout)11 Component (java.awt.Component)11 Dimension (java.awt.Dimension)11 ArrayList (java.util.ArrayList)11