Search in sources :

Example 26 with JMenuItem

use of javax.swing.JMenuItem in project adempiere by adempiere.

the class POSActionMenu method addMenuItem.

private void addMenuItem(String optionName) {
    JMenuItem menuItem = new JMenuItem(optionName);
    popupMenu.add(menuItem).addActionListener(this);
}
Also used : JMenuItem(javax.swing.JMenuItem)

Example 27 with JMenuItem

use of javax.swing.JMenuItem in project adempiere by adempiere.

the class CompiereToolTipUI method getAcceleratorString.

/**
     * 	Get Accelerator String
     *	@return string
     */
public String getAcceleratorString() {
    String str = super.getAcceleratorString();
    if (tip == null || isAcceleratorHidden())
        return str;
    JComponent comp = tip.getComponent();
    if (comp == null || comp instanceof JTabbedPane || comp instanceof JMenuItem)
        return str;
    KeyStroke[] keys = comp.getRegisteredKeyStrokes();
    StringBuffer controlKeyStr = new StringBuffer();
    for (int i = 0; i < keys.length; i++) {
        int mod = keys[i].getModifiers();
        int condition = comp.getConditionForKeyStroke(keys[i]);
        if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
            String prefix = KeyEvent.getKeyModifiersText(mod);
            if (prefix.length() > 1) {
                if (controlKeyStr.length() > 0)
                    controlKeyStr.append("  ");
                controlKeyStr.append(prefix).append("-").append(KeyEvent.getKeyText(keys[i].getKeyCode()));
                //	just first
                break;
            }
        }
    }
    return controlKeyStr.toString();
}
Also used : JTabbedPane(javax.swing.JTabbedPane) JComponent(javax.swing.JComponent) KeyStroke(javax.swing.KeyStroke) JMenuItem(javax.swing.JMenuItem)

Example 28 with JMenuItem

use of javax.swing.JMenuItem in project jmeter by apache.

the class MenuFactory method makeMenuItem.

public static JMenuItem makeMenuItem(String label, String name, String actionCommand, KeyStroke accel) {
    JMenuItem item = makeMenuItem(label, name, actionCommand);
    item.setAccelerator(accel);
    return item;
}
Also used : JMenuItem(javax.swing.JMenuItem)

Example 29 with JMenuItem

use of javax.swing.JMenuItem in project joda-time by JodaOrg.

the class DateTimeBrowser method addMenus.

/*
     * addMenus
     */
private void addMenus(JMenuBar menuBar) {
    //
    // Create all the menus.
    //
    JMenu fileMenu = new JMenu("File");
    JMenu viewMenu = new JMenu("View");
    //
    // Add them to the menubar in order.
    //
    menuBar.add(fileMenu);
    menuBar.add(viewMenu);
    //
    // Create action objects and menu items.
    //
    Action open = new OpenAction();
    JMenuItem jmiOpen = new JMenuItem(open);
    Action exit = new ExitAction();
    JMenuItem jmiExit = new JMenuItem(exit);
    //
    // Next Menu
    //
    Action getter = new GetterAction();
    jmiGetter = new JMenuItem(getter);
    getter.setEnabled(true);
    //
    Action hex = new HexAction();
    jmiHex = new JMenuItem(hex);
    hex.setEnabled(true);
    //
    Action date = new DateAction();
    jmiDate = new JMenuItem(date);
    date.setEnabled(true);
    //
    Action cal = new CalAction();
    jmiCal = new JMenuItem(cal);
    cal.setEnabled(true);
    //
    // Build the file menu.
    //
    fileMenu.add(jmiOpen);
    fileMenu.addSeparator();
    fileMenu.add(jmiExit);
    //
    // Build the view menu.
    //
    viewMenu.add(jmiGetter);
    viewMenu.add(jmiHex);
    viewMenu.add(jmiDate);
    viewMenu.add(jmiCal);
//
// *temp Developer's code
//
// jmiGetter.setEnabled( false );
//
// JMenuItem getter2 = new JMenuItem( "getter2" );
// getter2.addActionListener( new myMouseListener() );
// viewMenu.add( getter2 );
}
Also used : Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Example 30 with JMenuItem

use of javax.swing.JMenuItem in project jadx by skylot.

the class TabbedPane method createTabPopupMenu.

private JPopupMenu createTabPopupMenu(final ContentPanel contentPanel) {
    JPopupMenu menu = new JPopupMenu();
    JMenuItem closeTab = new JMenuItem(NLS.str("tabs.close"));
    closeTab.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            closeCodePanel(contentPanel);
        }
    });
    menu.add(closeTab);
    if (openTabs.size() > 1) {
        JMenuItem closeOther = new JMenuItem(NLS.str("tabs.closeOthers"));
        closeOther.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                List<ContentPanel> contentPanels = new ArrayList<ContentPanel>(openTabs.values());
                for (ContentPanel panel : contentPanels) {
                    if (panel != contentPanel) {
                        closeCodePanel(panel);
                    }
                }
            }
        });
        menu.add(closeOther);
        JMenuItem closeAll = new JMenuItem(NLS.str("tabs.closeAll"));
        closeAll.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                closeAllTabs();
            }
        });
        menu.add(closeAll);
        menu.addSeparator();
        ContentPanel selectedContentPanel = getSelectedCodePanel();
        for (final Map.Entry<JNode, ContentPanel> entry : openTabs.entrySet()) {
            final ContentPanel cp = entry.getValue();
            if (cp == selectedContentPanel) {
                continue;
            }
            JNode node = entry.getKey();
            final String clsName = node.makeLongString();
            JMenuItem item = new JMenuItem(clsName);
            item.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    setSelectedComponent(cp);
                }
            });
            item.setIcon(node.getIcon());
            menu.add(item);
        }
    }
    return menu;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) List(java.util.List) JNode(jadx.gui.treemodel.JNode) JMenuItem(javax.swing.JMenuItem) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) JPopupMenu(javax.swing.JPopupMenu)

Aggregations

JMenuItem (javax.swing.JMenuItem)1138 ActionEvent (java.awt.event.ActionEvent)559 ActionListener (java.awt.event.ActionListener)463 JMenu (javax.swing.JMenu)373 JPopupMenu (javax.swing.JPopupMenu)229 JMenuBar (javax.swing.JMenuBar)104 AbstractAction (javax.swing.AbstractAction)90 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)76 ArrayList (java.util.ArrayList)72 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