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);
}
}
}
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);
}
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));
}
use of java.awt.MenuItem in project litiengine by gurkenlabs.
the class Program method initViewMenu.
private static Menu initViewMenu() {
Menu mnView = new Menu(Resources.get("menu_view"));
CheckboxMenuItem snapToGrid = new CheckboxMenuItem(Resources.get("menu_snapGrid"));
snapToGrid.setState(userPreferences.isSnapGrid());
EditorScreen.instance().getMapComponent().setSnapToGrid(snapToGrid.getState());
snapToGrid.addItemListener(e -> {
EditorScreen.instance().getMapComponent().setSnapToGrid(snapToGrid.getState());
userPreferences.setSnapGrid(snapToGrid.getState());
});
CheckboxMenuItem renderGrid = new CheckboxMenuItem(Resources.get("menu_renderGrid"));
renderGrid.setState(userPreferences.isShowGrid());
EditorScreen.instance().getMapComponent().setRenderGrid(renderGrid.getState());
renderGrid.setShortcut(new MenuShortcut(KeyEvent.VK_G));
renderGrid.addItemListener(e -> {
EditorScreen.instance().getMapComponent().setRenderGrid(renderGrid.getState());
userPreferences.setShowGrid(renderGrid.getState());
});
CheckboxMenuItem renderCollision = new CheckboxMenuItem(Resources.get("menu_renderCollisionBoxes"));
renderCollision.setState(userPreferences.isRenderBoundingBoxes());
EditorScreen.instance().getMapComponent().setRenderCollisionBoxes(renderCollision.getState());
renderCollision.setShortcut(new MenuShortcut(KeyEvent.VK_H));
renderCollision.addItemListener(e -> {
EditorScreen.instance().getMapComponent().setRenderCollisionBoxes(renderCollision.getState());
userPreferences.setRenderBoundingBoxes(renderCollision.getState());
});
MenuItem setGrid = new MenuItem(Resources.get("menu_gridSize"));
setGrid.addActionListener(a -> {
GridEditPanel panel = new GridEditPanel(EditorScreen.instance().getMapComponent().getGridSize());
int option = JOptionPane.showConfirmDialog(Game.getScreenManager().getRenderComponent(), panel, Resources.get("menu_gridSettings"), JOptionPane.DEFAULT_OPTION);
if (option == JOptionPane.OK_OPTION) {
EditorScreen.instance().getMapComponent().setGridSize(panel.getGridSize());
}
});
MenuItem zoomIn = new MenuItem(Resources.get("menu_zoomIn"));
zoomIn.setShortcut(new MenuShortcut(KeyEvent.VK_PLUS));
zoomIn.addActionListener(a -> EditorScreen.instance().getMapComponent().zoomIn());
MenuItem zoomOut = new MenuItem(Resources.get("menu_zoomOut"));
zoomOut.setShortcut(new MenuShortcut(KeyEvent.VK_MINUS));
zoomOut.addActionListener(a -> EditorScreen.instance().getMapComponent().zoomOut());
mnView.add(snapToGrid);
mnView.add(renderGrid);
mnView.add(renderCollision);
mnView.add(setGrid);
mnView.addSeparator();
mnView.add(zoomIn);
mnView.add(zoomOut);
return mnView;
}
use of java.awt.MenuItem in project litiengine by gurkenlabs.
the class Program method initSystemTray.
private static void initSystemTray() {
// add system tray icon with popup menu
if (SystemTray.isSupported()) {
SystemTray tray = SystemTray.getSystemTray();
PopupMenu menu = new PopupMenu();
MenuItem exitItem = new MenuItem(Resources.get("menu_exit"));
exitItem.addActionListener(a -> Game.terminate());
menu.add(exitItem);
trayIcon = new TrayIcon(Resources.getImage("pixel-icon-utility.png"), Game.getInfo().toString(), menu);
trayIcon.setImageAutoSize(true);
try {
tray.add(trayIcon);
} catch (AWTException e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
}
}
Aggregations