@Override public void run() { _native.setShortcut(new MenuShortcut(vKey)); } });
public boolean onMenuOpened(int featureid, Menu menu) { menu.clear(); if (!editable) { MenuItem itemAdd = menu.add(0, REASSIGN, Menu.NONE, context.getString(R.string.reassign)); MenuItem itemMod = menu.add(1, EDIT, Menu.NONE, context.getString(R.string.modify)); MenuItem itemDel = menu.add(2, DELETE, Menu.NONE, context.getString(R.string.delete)); itemAdd.setShortcut('0', 'a'); itemMod.setShortcut('1', 'm'); itemDel.setShortcut('2', 'd'); } else { MenuItem itemSave = menu.add(3, SAVE, Menu.NONE, context.getString(R.string.savechanges)); itemSave.setShortcut('0', 'S'); } return true; }
this.openFile.setShortcut(new MenuShortcut(KeyEvent.VK_O, false)); this.saveFile.setShortcut(new MenuShortcut(KeyEvent.VK_S, false)); this.close.setShortcut(new MenuShortcut(KeyEvent.VK_F4, false));
this.openFile.setShortcut(new MenuShortcut(KeyEvent.VK_O, false)); // set a keyboard shortcut this.saveFile.setShortcut(new MenuShortcut(KeyEvent.VK_S, false)); this.close.setShortcut(new MenuShortcut(KeyEvent.VK_F4, false));
normalFont.addActionListener(this); openFile.addActionListener(this); openFile.setShortcut(new MenuShortcut(KeyEvent.VK_0, false)); file.add(this.openFile); saveFile.setLabel("Save"); saveFile.addActionListener(this); saveFile.setShortcut(new MenuShortcut(KeyEvent.VK_S, false)); file.add(this.saveFile); close.setLabel("Close"); close.setShortcut(new MenuShortcut(KeyEvent.VK_F4, false)); close.addActionListener(this); file.add(this.close);
private void assignProperties(final MenuItem menuItem, final ShadowMenu shadow) { final Accelerator acc = shadow.getMenuEntry().getAccelerator(); if (acc != null) { final int code = acc.getKeyCode().getCode(); final boolean shift = acc.getModifiers().isShiftDown(); final MenuShortcut shortcut = new MenuShortcut(code, shift); menuItem.setShortcut(shortcut); } final ModuleInfo info = shadow.getModuleInfo(); if (info != null) menuItem.setEnabled(info.isEnabled()); }
private static Menu initFileMenu() { Menu mnFile = new Menu(Resources.strings().get("menu_file")); MenuItem create = new MenuItem(Resources.strings().get("menu_createProject")); create.setShortcut(new MenuShortcut(KeyEvent.VK_N)); create.addActionListener(a -> EditorScreen.instance().create()); MenuItem load = new MenuItem(Resources.strings().get("menu_loadProject")); load.setShortcut(new MenuShortcut(KeyEvent.VK_O)); load.addActionListener(a -> EditorScreen.instance().load()); MenuItem save = new MenuItem(Resources.strings().get("menu_save")); save.setShortcut(new MenuShortcut(KeyEvent.VK_S)); save.addActionListener(a -> EditorScreen.instance().save(false)); MenuItem saveAs = new MenuItem(Resources.strings().get("menu_saveAs")); saveAs.addActionListener(a -> EditorScreen.instance().save(true)); MenuItem exit = new MenuItem(Resources.strings().get("menu_exit")); exit.setShortcut(new MenuShortcut(KeyEvent.VK_Q)); exit.addActionListener(a -> System.exit(0)); mnFile.add(load); mnFile.add(create); mnFile.add(save); mnFile.add(saveAs); mnFile.addSeparator(); recentFiles = new Menu(Resources.strings().get("menu_recentFiles")); loadRecentFiles(); mnFile.add(recentFiles); mnFile.addSeparator(); mnFile.add(exit); return mnFile; }
saveMapSnapshot.setShortcut(new MenuShortcut(KeyEvent.VK_ENTER)); saveMapSnapshot.addActionListener(a -> EditorScreen.instance().saveMapSnapshot()); mapProps.setShortcut(new MenuShortcut(KeyEvent.VK_M)); mapProps.addActionListener(a -> { if (EditorScreen.instance().getMapComponent().getMaps() == null || EditorScreen.instance().getMapComponent().getMaps().isEmpty()) {
zoomIn.setShortcut(new MenuShortcut(KeyEvent.VK_PLUS)); zoomIn.addActionListener(a -> EditorScreen.instance().getMapComponent().zoomIn()); zoomOut.setShortcut(new MenuShortcut(KeyEvent.VK_MINUS)); zoomOut.addActionListener(a -> EditorScreen.instance().getMapComponent().zoomOut());