Search in sources :

Example 66 with JMenuItem

use of javax.swing.JMenuItem in project jdk8u_jdk by JetBrains.

the class MetalworksFrame method buildViewsMenu.

protected JMenu buildViewsMenu() {
    JMenu views = new JMenu("Views");
    JMenuItem inBox = new JMenuItem("Open In-Box");
    JMenuItem outBox = new JMenuItem("Open Out-Box");
    outBox.setEnabled(false);
    inBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            openInBox();
        }
    });
    views.add(inBox);
    views.add(outBox);
    return views;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Example 67 with JMenuItem

use of javax.swing.JMenuItem in project jdk8u_jdk by JetBrains.

the class MetalworksFrame method buildEditMenu.

protected JMenu buildEditMenu() {
    JMenu edit = new JMenu("Edit");
    JMenuItem undo = new JMenuItem("Undo");
    JMenuItem copy = new JMenuItem("Copy");
    JMenuItem cut = new JMenuItem("Cut");
    JMenuItem paste = new JMenuItem("Paste");
    JMenuItem prefs = new JMenuItem("Preferences...");
    undo.setEnabled(false);
    copy.setEnabled(false);
    cut.setEnabled(false);
    paste.setEnabled(false);
    prefs.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            openPrefsWindow();
        }
    });
    edit.add(undo);
    edit.addSeparator();
    edit.add(cut);
    edit.add(copy);
    edit.add(paste);
    edit.addSeparator();
    edit.add(prefs);
    return edit;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Example 68 with JMenuItem

use of javax.swing.JMenuItem in project jdk8u_jdk by JetBrains.

the class ScreenMenuMemoryLeakTest method removeMenuItemFromMenu.

private static void removeMenuItemFromMenu() {
    JMenuItem menuItem = sMenuItem.get();
    Objects.requireNonNull(menuItem, "The menu item should still be available at this point");
    sMenu.remove(menuItem);
}
Also used : JMenuItem(javax.swing.JMenuItem)

Example 69 with JMenuItem

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

the class EntryEditor method setupToolBar.

private void setupToolBar() {
    JPanel leftPan = new JPanel();
    leftPan.setLayout(new BorderLayout());
    JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL);
    toolBar.setBorder(null);
    toolBar.setRollover(true);
    toolBar.setMargin(new Insets(0, 0, 0, 2));
    // The toolbar carries all the key bindings that are valid for the whole window.
    ActionMap actionMap = toolBar.getActionMap();
    InputMap inputMap = toolBar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_ENTRY_EDITOR), "close");
    actionMap.put("close", closeAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_STORE_FIELD), "store");
    actionMap.put("store", storeFieldAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.AUTOGENERATE_BIBTEX_KEYS), "generateKey");
    actionMap.put("generateKey", generateKeyAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.AUTOMATICALLY_LINK_FILES), "autoLink");
    actionMap.put("autoLink", autoLinkAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_PREVIOUS_ENTRY), "prev");
    actionMap.put("prev", prevEntryAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_NEXT_ENTRY), "next");
    actionMap.put("next", nextEntryAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.UNDO), "undo");
    actionMap.put("undo", undoAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.REDO), "redo");
    actionMap.put("redo", redoAction);
    inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.HELP), "help");
    actionMap.put("help", helpAction);
    toolBar.setFloatable(false);
    // Add actions (and thus buttons)
    JButton closeBut = new JButton(closeAction);
    closeBut.setText(null);
    closeBut.setBorder(null);
    closeBut.setMargin(new Insets(8, 0, 8, 0));
    leftPan.add(closeBut, BorderLayout.NORTH);
    // Create type-label
    TypedBibEntry typedEntry = new TypedBibEntry(entry, panel.getBibDatabaseContext().getMode());
    leftPan.add(new TypeLabel(typedEntry.getTypeForDisplay()), BorderLayout.CENTER);
    TypeButton typeButton = new TypeButton();
    toolBar.add(typeButton);
    toolBar.add(generateKeyAction);
    toolBar.add(autoLinkAction);
    toolBar.add(writeXmp);
    JPopupMenu fetcherPopup = new JPopupMenu();
    for (EntryBasedFetcher fetcher : WebFetchers.getEntryBasedFetchers(Globals.prefs.getImportFormatPreferences())) {
        fetcherPopup.add(new JMenuItem(new AbstractAction(fetcher.getName()) {

            @Override
            public void actionPerformed(ActionEvent e) {
                new EntryFetchAndMergeWorker(panel, getEntry(), fetcher).execute();
            }
        }));
    }
    JButton fetcherButton = new JButton(IconTheme.JabRefIcon.REFRESH.getIcon());
    fetcherButton.setToolTipText(Localization.lang("Update with bibliographic information from the web"));
    fetcherButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            fetcherPopup.show(e.getComponent(), e.getX(), e.getY());
        }
    });
    toolBar.add(fetcherButton);
    toolBar.addSeparator();
    toolBar.add(deleteAction);
    toolBar.add(prevEntryAction);
    toolBar.add(nextEntryAction);
    toolBar.addSeparator();
    toolBar.add(helpAction);
    Component[] comps = toolBar.getComponents();
    for (Component comp : comps) {
        ((JComponent) comp).setOpaque(false);
    }
    leftPan.add(toolBar, BorderLayout.SOUTH);
    add(leftPan, BorderLayout.WEST);
}
Also used : JPanel(javax.swing.JPanel) Insets(java.awt.Insets) MouseEvent(java.awt.event.MouseEvent) ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) JComponent(javax.swing.JComponent) EntryFetchAndMergeWorker(org.jabref.gui.mergeentries.EntryFetchAndMergeWorker) JToolBar(javax.swing.JToolBar) TypedBibEntry(org.jabref.logic.TypedBibEntry) JPopupMenu(javax.swing.JPopupMenu) BorderLayout(java.awt.BorderLayout) OSXCompatibleToolbar(org.jabref.gui.OSXCompatibleToolbar) InputMap(javax.swing.InputMap) EntryBasedFetcher(org.jabref.logic.importer.EntryBasedFetcher) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) JComponent(javax.swing.JComponent) JTextComponent(javax.swing.text.JTextComponent) AbstractAction(javax.swing.AbstractAction)

Example 70 with JMenuItem

use of javax.swing.JMenuItem 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)

Aggregations

JMenuItem (javax.swing.JMenuItem)1130 ActionEvent (java.awt.event.ActionEvent)559 ActionListener (java.awt.event.ActionListener)464 JMenu (javax.swing.JMenu)369 JPopupMenu (javax.swing.JPopupMenu)225 JMenuBar (javax.swing.JMenuBar)103 AbstractAction (javax.swing.AbstractAction)90 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)76 ArrayList (java.util.ArrayList)71 JPanel (javax.swing.JPanel)70 Point (java.awt.Point)65 JSeparator (javax.swing.JSeparator)63 File (java.io.File)61 JLabel (javax.swing.JLabel)61 BorderLayout (java.awt.BorderLayout)57 JButton (javax.swing.JButton)54 Component (java.awt.Component)53 ButtonGroup (javax.swing.ButtonGroup)50 Dimension (java.awt.Dimension)46 MouseEvent (java.awt.event.MouseEvent)45