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);
}
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);
}
}
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;
}
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());
}
}
}
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;
}
Aggregations