Search in sources :

Example 1 with MenuItem

use of java.awt.MenuItem in project cryptomator by cryptomator.

the class ExitUtil method createTrayIcon.

private TrayIcon createTrayIcon(Runnable exitCommand) {
    final PopupMenu popup = new PopupMenu();
    final MenuItem showItem = new MenuItem(localization.getString("tray.menu.open"));
    showItem.addActionListener(this::restoreFromTray);
    popup.add(showItem);
    final MenuItem exitItem = new MenuItem(localization.getString("tray.menu.quit"));
    exitItem.addActionListener(e -> exitCommand.run());
    popup.add(exitItem);
    final Image image;
    if (SystemUtils.IS_OS_MAC_OSX && isMacMenuBarDarkMode()) {
        image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/tray_icon_mac_white.png"));
    } else if (SystemUtils.IS_OS_MAC_OSX) {
        image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/tray_icon_mac_black.png"));
    } else {
        image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/tray_icon.png"));
    }
    return new TrayIcon(image, localization.getString("app.name"), popup);
}
Also used : TrayIcon(java.awt.TrayIcon) MenuItem(java.awt.MenuItem) Image(java.awt.Image) PopupMenu(java.awt.PopupMenu)

Example 2 with MenuItem

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

the class DatabaseManager method addMenuItems.

void addMenuItems(Menu f, String[] m) {
    for (int i = 0; i < m.length; i++) {
        MenuItem item = new MenuItem(m[i].substring(1));
        char c = m[i].charAt(0);
        if (c != '-') {
            item.setShortcut(new MenuShortcut(c));
        }
        item.addActionListener(this);
        f.add(item);
    }
}
Also used : MenuItem(java.awt.MenuItem) MenuShortcut(java.awt.MenuShortcut)

Example 3 with MenuItem

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

the class DatabaseManager method addToRecent.

private void addToRecent(String s) {
    for (int i = 0; i < iMaxRecent; i++) {
        if (s.equals(sRecent[i])) {
            return;
        }
    }
    if (sRecent[iRecent] != null) {
        mRecent.remove(iRecent);
    }
    sRecent[iRecent] = s;
    if (s.length() > 43) {
        s = s.substring(0, 40) + "...";
    }
    MenuItem item = new MenuItem(s);
    item.setActionCommand("#" + iRecent);
    item.addActionListener(this);
    mRecent.insert(item, iRecent);
    iRecent = (iRecent + 1) % iMaxRecent;
}
Also used : MenuItem(java.awt.MenuItem)

Example 4 with MenuItem

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

the class CMenu method setEnabled.

@Override
public final void setEnabled(final boolean b) {
    super.setEnabled(b);
    final Menu target = (Menu) getTarget();
    final int count = target.getItemCount();
    for (int i = 0; i < count; ++i) {
        MenuItem item = target.getItem(i);
        MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item);
        if (p != null) {
            p.setEnabled(b && item.isEnabled());
        }
    }
}
Also used : MenuItemPeer(java.awt.peer.MenuItemPeer) MenuItem(java.awt.MenuItem) Menu(java.awt.Menu)

Example 5 with MenuItem

use of java.awt.MenuItem in project processdash by dtuma.

the class MenuHandler method makeShowWindowMenuItem.

private MenuItem makeShowWindowMenuItem(ProcessDashboard pdash) {
    String windowTitle = pdash.getTitle();
    String menuText = res.format("Show_Window_FMT", windowTitle);
    MenuItem showWindow = new MenuItem(menuText);
    showWindow.addActionListener(showWindowAction);
    return showWindow;
}
Also used : MenuItem(java.awt.MenuItem)

Aggregations

MenuItem (java.awt.MenuItem)50 PopupMenu (java.awt.PopupMenu)21 Menu (java.awt.Menu)15 JMenuItem (javax.swing.JMenuItem)15 JPopupMenu (javax.swing.JPopupMenu)13 TrayIcon (java.awt.TrayIcon)10 MenuShortcut (java.awt.MenuShortcut)9 ActionEvent (java.awt.event.ActionEvent)9 CheckboxMenuItem (java.awt.CheckboxMenuItem)8 ActionListener (java.awt.event.ActionListener)8 AWTException (java.awt.AWTException)7 Image (java.awt.Image)7 SystemTray (java.awt.SystemTray)6 IOException (java.io.IOException)6 Dimension (java.awt.Dimension)4 File (java.io.File)4 FileDialog (java.awt.FileDialog)3 URL (java.net.URL)3 SQLException (java.sql.SQLException)3 JMenu (javax.swing.JMenu)3