Search in sources :

Example 16 with MenuItem

use of java.awt.MenuItem in project voltdb by VoltDB.

the class Transfer method addMenuItems.

/**
     * Method declaration
     *
     *
     * @param f
     * @param m
     */
private void addMenuItems(Menu f, String[] m) {
    for (int i = 0; i < m.length; i++) {
        if (m[i].equals("-")) {
            f.addSeparator();
        } else {
            MenuItem item = new MenuItem(m[i]);
            item.addActionListener(this);
            f.add(item);
        }
    }
}
Also used : MenuItem(java.awt.MenuItem)

Example 17 with MenuItem

use of java.awt.MenuItem in project jdk8u_jdk by JetBrains.

the class AWTInputMethodPopupMenu method addMenuItem.

void addMenuItem(Object targetMenu, String label, String command, String currentSelection) {
    MenuItem menuItem;
    if (isSelected(command, currentSelection)) {
        menuItem = new CheckboxMenuItem(label, true);
    } else {
        menuItem = new MenuItem(label);
    }
    menuItem.setActionCommand(command);
    menuItem.addActionListener(this);
    menuItem.setEnabled(command != null);
    ((Menu) targetMenu).add(menuItem);
}
Also used : CheckboxMenuItem(java.awt.CheckboxMenuItem) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) MenuItem(java.awt.MenuItem) JMenuItem(javax.swing.JMenuItem) CheckboxMenuItem(java.awt.CheckboxMenuItem) JPopupMenu(javax.swing.JPopupMenu) JMenu(javax.swing.JMenu) Menu(java.awt.Menu) PopupMenu(java.awt.PopupMenu)

Example 18 with MenuItem

use of java.awt.MenuItem in project jdk8u_jdk by JetBrains.

the class CMenuItem method setLabel.

public void setLabel(String label, char keyChar, int keyCode, int modifiers) {
    int keyMask = modifiers;
    if (keyCode == KeyEvent.VK_UNDEFINED) {
        MenuShortcut shortcut = ((MenuItem) getTarget()).getShortcut();
        if (shortcut != null) {
            keyCode = shortcut.getKey();
            keyMask |= InputEvent.META_MASK;
            if (shortcut.usesShiftModifier()) {
                keyMask |= InputEvent.SHIFT_MASK;
            }
        }
    }
    if (label == null) {
        label = "";
    }
    // CHAR_UNDEFINED into 0.
    if (keyChar == KeyEvent.CHAR_UNDEFINED) {
        keyChar = 0;
    }
    final String finalLabel = label;
    final char finalKeyChar = keyChar;
    final int finalKeyCode = keyCode;
    final int finalKeyMask = keyMask;
    execute(ptr -> nativeSetLabel(ptr, finalLabel, finalKeyChar, finalKeyCode, finalKeyMask));
}
Also used : MenuItem(java.awt.MenuItem) MenuShortcut(java.awt.MenuShortcut)

Aggregations

MenuItem (java.awt.MenuItem)18 PopupMenu (java.awt.PopupMenu)4 FileDialog (java.awt.FileDialog)3 Image (java.awt.Image)3 Menu (java.awt.Menu)3 MenuShortcut (java.awt.MenuShortcut)3 TrayIcon (java.awt.TrayIcon)3 AWTException (java.awt.AWTException)2 Dimension (java.awt.Dimension)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 SQLException (java.sql.SQLException)2 JMenuItem (javax.swing.JMenuItem)2 JPopupMenu (javax.swing.JPopupMenu)2 CheckboxMenuItem (java.awt.CheckboxMenuItem)1 Frame (java.awt.Frame)1 Insets (java.awt.Insets)1 MenuBar (java.awt.MenuBar)1 TextField (java.awt.TextField)1 WindowEvent (java.awt.event.WindowEvent)1