List of usage examples for java.awt.event KeyEvent VK_W
int VK_W
To view the source code for java.awt.event KeyEvent VK_W.
Click Source Link
From source file:org.tinymediamanager.ui.tvshows.TvShowPanel.java
/** * Builds the menu./* w w w .j av a 2 s . c om*/ */ private void buildMenu() { menu.setMnemonic(KeyEvent.VK_V); // menu items JMenuItem menuItem = menu.add(actionUpdateDatasources2); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menu.addSeparator(); JMenu menuScrape = new JMenu(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$ menuScrape.setMnemonic(KeyEvent.VK_S); menuItem = menuScrape.add(actionScrape2); menuItem.setMnemonic(KeyEvent.VK_S); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuScrape.add(actionScrapeSelected); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuScrape.add(actionScrapeNewItems); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menu.add(menuScrape); JMenu menuEdit = new JMenu(BUNDLE.getString("Button.edit")); //$NON-NLS-1$ menuEdit.setMnemonic(KeyEvent.VK_E); menuItem = menuEdit.add(actionEdit2); menuItem.setMnemonic(KeyEvent.VK_E); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionBatchEdit); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionSetWatchedFlag); menuItem.setMnemonic(KeyEvent.VK_W); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionChangeSeasonPoster2); menuItem.setMnemonic(KeyEvent.VK_S); menuEdit.add(actionChangeToDvdOrder); menuEdit.add(actionChangeToAiredOrder); menu.add(menuEdit); menu.add(actionRewriteTvShowNfo); menu.add(actionRewriteTvShowEpisodeNfo); menuItem = menu.add(actionRename); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menu.add(actionMediaInformation2); menuItem.setMnemonic(KeyEvent.VK_M); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menu.add(actionExport); menuItem.setMnemonic(KeyEvent.VK_X); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menu.add(actionClearImageCache); menuItem.setMnemonic(KeyEvent.VK_C); menu.addSeparator(); menuItem = menu.add(actionRemove2); menuItem.setAccelerator(KeyStroke.getKeyStroke((char) KeyEvent.VK_DELETE)); menuItem = menu.add(actionDelete2); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, ActionEvent.SHIFT_MASK)); menu.addSeparator(); menuItem = menu.add(actionSyncTrakt); menuItem.setMnemonic(KeyEvent.VK_T); menuItem = menu.add(actionSyncWatchedTrakt); menuItem.setMnemonic(KeyEvent.VK_W); menuItem = menu.add(actionSyncSelectedTrakt); // popup menu JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(actionScrape2); popupMenu.add(actionScrapeSelected); popupMenu.add(actionScrapeEpisodes); popupMenu.add(actionScrapeEpisodes2); popupMenu.add(actionScrapeNewItems); // popupMenu.add(actionScrapeMetadataSelected); popupMenu.addSeparator(); popupMenu.add(actionUpdateTvShow); popupMenu.addSeparator(); popupMenu.add(actionEdit2); popupMenu.add(actionChangeSeasonPoster2); popupMenu.add(actionBatchEdit); popupMenu.add(actionSetWatchedFlag); popupMenu.add(actionChangeToDvdOrder); popupMenu.add(actionChangeToAiredOrder); popupMenu.add(actionRewriteTvShowNfo); popupMenu.add(actionRewriteTvShowEpisodeNfo); // popupMenu.add(actionBatchEdit); popupMenu.add(actionRename); popupMenu.add(actionMediaInformation2); popupMenu.add(actionExport); popupMenu.add(actionClearImageCache); popupMenu.addSeparator(); popupMenu.add(actionDownloadSubtitles); popupMenu.add(actionSearchAndDownloadSubtitles); popupMenu.addSeparator(); popupMenu.add(actionSyncTrakt); popupMenu.add(actionSyncWatchedTrakt); popupMenu.add(actionSyncSelectedTrakt); popupMenu.addSeparator(); popupMenu.add(actionRemove2); popupMenu.add(actionDelete2); popupMenu.addSeparator(); popupMenu.add(new ExpandAllAction()); popupMenu.add(new CollapseAllAction()); if (Globals.isDebug()) { JMenu menuDebug = new JMenu("Debug"); //$NON-NLS-1$ menuDebug.add(debugDumpShow); popupMenu.addSeparator(); popupMenu.add(menuDebug); } MouseListener popupListener = new TreePopupListener(popupMenu, tree); tree.addMouseListener(popupListener); }
From source file:com.net2plan.gui.tools.GUINetworkDesign.java
private void addAllKeyCombinationActions() { addKeyCombinationAction("Resets the tool", new AbstractAction() { @Override// w w w. j a va2 s . c o m public void actionPerformed(ActionEvent e) { resetButton(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Outputs current design to console", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { System.out.println(getDesign().toString()); } }, KeyStroke.getKeyStroke(KeyEvent.VK_F11, InputEvent.CTRL_DOWN_MASK)); /* FROM THE OFFLINE ALGORITHM EXECUTION */ addKeyCombinationAction("Execute algorithm", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { executionPane.doClickInExecutionButton(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_DOWN_MASK)); /* From the TOPOLOGY PANEL */ addKeyCombinationAction("Load design", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { topologyPanel.loadDesign(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Save design", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { topologyPanel.saveDesign(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Zoom in", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (topologyPanel.getSize().getWidth() != 0 && topologyPanel.getSize().getHeight() != 0) topologyPanel.getCanvas().zoomIn(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ADD, InputEvent.CTRL_DOWN_MASK), KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Zoom out", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (topologyPanel.getSize().getWidth() != 0 && topologyPanel.getSize().getHeight() != 0) topologyPanel.getCanvas().zoomOut(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, InputEvent.CTRL_DOWN_MASK), KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Zoom all", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (topologyPanel.getSize().getWidth() != 0 && topologyPanel.getSize().getHeight() != 0) topologyPanel.getCanvas().zoomAll(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_MULTIPLY, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Take snapshot", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { topologyPanel.takeSnapshot(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_F12, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Load traffic demands", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { topologyPanel.loadTrafficDemands(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK)); /* FROM REPORT */ addKeyCombinationAction("Close selected report", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { int tab = reportPane.getReportContainer().getSelectedIndex(); if (tab == -1) return; reportPane.getReportContainer().remove(tab); } }, KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Close all reports", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { reportPane.getReportContainer().removeAll(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); /* Online simulation */ addKeyCombinationAction("Run simulation", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { try { if (onlineSimulationPane.isRunButtonEnabled()) onlineSimulationPane.runSimulation(false); } catch (Net2PlanException ex) { if (ErrorHandling.isDebugEnabled()) ErrorHandling.addErrorOrException(ex, OnlineSimulationPane.class); ErrorHandling.showErrorDialog(ex.getMessage(), "Error executing simulation"); } catch (Throwable ex) { ErrorHandling.addErrorOrException(ex, OnlineSimulationPane.class); ErrorHandling.showErrorDialog("An error happened"); } } }, KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK)); // Windows addKeyCombinationAction("Show control window", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { WindowController.showTablesWindow(true); } }, KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK + ActionEvent.SHIFT_MASK)); viewEditTopTables.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); viewEditTopTables.setActionMap(this.getActionMap()); reportPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); reportPane.setActionMap(this.getActionMap()); executionPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); executionPane.setActionMap(this.getActionMap()); onlineSimulationPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); onlineSimulationPane.setActionMap(this.getActionMap()); whatIfAnalysisPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); whatIfAnalysisPane.setActionMap(this.getActionMap()); }
From source file:util.ui.UiUtilities.java
/** * Registers the escape key as close key for a component. * * @param component//from w w w . j ava2s .com * The component to close on pressing escape key. */ public static void registerForClosing(final WindowClosingIf component) { Action a = new AbstractAction() { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { component.close(); } }; if (OperatingSystem.isMacOs()) { // Add MacOS Apple+W for Closing of Dialogs KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.META_DOWN_MASK); component.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "CLOSE_ON_APPLE_W"); component.getRootPane().getActionMap().put("CLOSE_ON_APPLE_W", a); stroke = KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.META_DOWN_MASK); component.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "CLOSE_COMPLETE_ON_APPLE"); component.getRootPane().getActionMap().put("CLOSE_COMPLETE_ON_APPLE", new AbstractAction() { public void actionPerformed(ActionEvent e) { MainFrame.getInstance().quit(); } }); } KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); component.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "CLOSE_ON_ESCAPE"); component.getRootPane().getActionMap().put("CLOSE_ON_ESCAPE", a); }
From source file:com.jcraft.weirdx.DDXWindowImpSwing.java
public void keyPressed(KeyEvent e) { if (!window.isMapped()) return;//from w ww . j av a 2s. c o m if (e.getKeyCode() == KeyEvent.VK_CAPS_LOCK) { if (clck_toggle) { clck_toggle = false; XWindow.sprite.hot.state &= (~1); } else { clck_toggle = true; XWindow.sprite.hot.state |= 1; } } // Easter Egg... if (window == window.screen.root && 0 < px && px < 3 && 0 < py && py < 3) { if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_W) { LogoImage.toggle(); } else if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_E) { XWindow.printWindowTree(window.screen.root); } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_I){ // if(WeirdX.acontext!=null){ // acontext.showDocument(new URL("http://www.weirdx.org/"), "_blank"); // } // } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_R){ // } // } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_D){ // } // } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_X){ // } // } } XWindow dest = XWindow.sprite.win; if (XWindow.focus.window != null) dest = XWindow.focus.window; if (window.screen.windowmode != 0 && dest == window.screen.root) { if (XWindow.focus.window != null) dest = XWindow.sprite.win; else dest = window; } if (dest.client == null) return; int kcode = Keymap.km.getCode(e); event.mkKeyPress(kcode, window.screen.rootId, dest.id, 0, XWindow.sprite.hot.x, XWindow.sprite.hot.y, XWindow.sprite.hot.x - window.x, XWindow.sprite.hot.y - window.y, XWindow.sprite.hot.state, 1); try { if (XWindow.grab != null) XWindow.sendGrabbedEvent(event, false, 1); else XWindow.sendDeviceEvent(dest, event, XWindow.grab, null, 1); } catch (Exception ee) { } kcode = e.getKeyCode(); int state = XWindow.sprite.hot.state; if (kcode == KeyEvent.VK_CONTROL) { if ((state & 4) == 0) state |= 4; } else if (kcode == KeyEvent.VK_SHIFT) { if ((state & 1) == 0) state |= 1; } else if (kcode == KeyEvent.VK_ALT) { if ((state & 8) == 0) state |= 8; } else if (kcode == VK_ALT_GRAPH) { if ((state & ALT_GR_MASK) == 0) state |= ALT_GR_MASK; } // check for windoze ALT_GR (is equal to ALT+CONTROL), by Marcus. if ((state & 12) == 12) { state -= 12; state |= ALT_GR_MASK; } XWindow.sprite.hot.state = state; }
From source file:com.jcraft.weirdx.DDXWindowImp.java
public void keyPressed(KeyEvent e) { if (!window.isMapped()) return;//from www. j av a2 s. co m if (e.getKeyCode() == KeyEvent.VK_CAPS_LOCK) { if (clck_toggle) { clck_toggle = false; XWindow.sprite.hot.state &= (~1); } else { clck_toggle = true; XWindow.sprite.hot.state |= 1; } } // Easter Egg... if (window == window.screen.root && 0 < px && px < 3 && 0 < py && py < 3) { if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_W) { LogoImage.toggle(); } else if (((e.getModifiers() & InputEvent.CTRL_MASK) != 0) && e.getKeyCode() == KeyEvent.VK_E) { XWindow.printWindowTree(window.screen.root); } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_I){ // if(WeirdX.acontext!=null){ // acontext.showDocument(new URL("http://www.weirdx.org/"), "_blank"); // } // } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_R){ // } // } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_D){ // } // } // else if(((e.getModifiers() & InputEvent.CTRL_MASK)!=0) && // e.getKeyCode()==KeyEvent.VK_X){ // } // } } XWindow dest = XWindow.sprite.win; if (XWindow.focus.window != null) dest = XWindow.focus.window; if (window.screen.windowmode != 0 && dest == window.screen.root) { if (XWindow.focus.window != null) dest = XWindow.sprite.win; else dest = window; } if (dest.client == null) return; int kcode = Keymap.km.getCode(e); event.mkKeyPress(kcode, window.screen.rootId, dest.id, 0, XWindow.sprite.hot.x, XWindow.sprite.hot.y, XWindow.sprite.hot.x - window.x, XWindow.sprite.hot.y - window.y, XWindow.sprite.hot.state, 1); try { if (XWindow.grab != null) XWindow.sendGrabbedEvent(event, false, 1); else XWindow.sendDeviceEvent(dest, event, XWindow.grab, null, 1); } catch (Exception ee) { } kcode = e.getKeyCode(); int state = XWindow.sprite.hot.state; if (kcode == KeyEvent.VK_CONTROL) { if ((state & 4) == 0) state |= 4; } else if (kcode == KeyEvent.VK_SHIFT) { if ((state & 1) == 0) state |= 1; } else if (kcode == KeyEvent.VK_ALT) { if ((state & 8) == 0) state |= 8; } else if (kcode == VK_ALT_GRAPH) { if ((state & ALT_GR_MASK) == 0) state |= ALT_GR_MASK; } // check for windoze ALT_GR (is equal to ALT+CONTROL) if ((state & 12) == 12) { state -= 12; state |= ALT_GR_MASK; } XWindow.sprite.hot.state = state; }
From source file:org.omegat.gui.scripting.ScriptingWindow.java
private JMenuBar createMenuBar() { mb = new JMenuBar(); JMenu menu = new JMenu(); Mnemonics.setLocalizedText(menu, OStrings.getString("SCW_MENU_TITLE")); JMenuItem item;//from ww w . ja va 2 s. c om item = new JMenuItem(); Mnemonics.setLocalizedText(item, OStrings.getString("SCW_NEW_SCRIPT")); item.addActionListener(new NewScriptAction()); item.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu.add(item); item = new JMenuItem(); Mnemonics.setLocalizedText(item, OStrings.getString("SCW_SAVE_SCRIPT")); item.addActionListener(new SaveScriptAction()); item.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu.add(item); item = new JMenuItem(); Mnemonics.setLocalizedText(item, OStrings.getString("SCW_RUN_SCRIPT")); item.addActionListener(new RunScriptAction()); item.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu.add(item); menu.addSeparator(); item = new JMenuItem(); Mnemonics.setLocalizedText(item, OStrings.getString("SCW_MENU_SET_SCRIPTS_FOLDER")); item.addActionListener(new SelectScriptFolderAction()); menu.add(item); item = new JMenuItem(); Mnemonics.setLocalizedText(item, OStrings.getString("SCW_MENU_ACCESS_FOLDER")); item.addActionListener(new ExploreScriptFolderAction()); menu.add(item); menu.addSeparator(); item = new JMenuItem(); Mnemonics.setLocalizedText(item, OStrings.getString("SCW_MENU_CLOSE")); item.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); item.addActionListener(e -> { frame.setVisible(false); frame.dispose(); }); menu.add(item); PropertiesShortcuts.MainMenuShortcuts.bindKeyStrokes(menu); mb.add(menu); // Edit Menu m_txtScriptEditor.enhanceMenu(mb); buildSetsMenu(mb); return mb; }
From source file:org.sikuli.ide.SikuliIDE.java
private void initFileMenu() throws NoSuchMethodException { JMenuItem jmi;//from w ww . jav a2 s .c o m int scMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); _fileMenu.setMnemonic(java.awt.event.KeyEvent.VK_F); if (showAbout) { _fileMenu.add( createMenuItem("About SikuliX", KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, scMask), new FileAction(FileAction.ABOUT))); _fileMenu.addSeparator(); } _fileMenu.add(createMenuItem(_I("menuFileNew"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, scMask), new FileAction(FileAction.NEW))); jmi = _fileMenu.add(createMenuItem(_I("menuFileOpen"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, scMask), new FileAction(FileAction.OPEN))); jmi.setName("OPEN"); recentMenu = new JMenu(_I("menuRecent")); if (Settings.experimental) { _fileMenu.add(recentMenu); } if (Settings.isMac() && !Settings.handlesMacBundles) { _fileMenu.add(createMenuItem("Open folder.sikuli ...", null, // KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, scMask), new FileAction(FileAction.OPEN_FOLDER))); } jmi = _fileMenu.add(createMenuItem(_I("menuFileSave"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, scMask), new FileAction(FileAction.SAVE))); jmi.setName("SAVE"); jmi = _fileMenu.add(createMenuItem(_I("menuFileSaveAs"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, InputEvent.SHIFT_MASK | scMask), new FileAction(FileAction.SAVE_AS))); jmi.setName("SAVE_AS"); if (Settings.isMac() && !Settings.handlesMacBundles) { _fileMenu.add(createMenuItem(_I("Save as folder.sikuli ..."), // KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, // InputEvent.SHIFT_MASK | scMask), null, new FileAction(FileAction.SAVE_AS_FOLDER))); } //TODO _fileMenu.add(createMenuItem(_I("menuFileSaveAll"), _fileMenu.add(createMenuItem("Save all", KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, InputEvent.CTRL_MASK | scMask), new FileAction(FileAction.SAVE_ALL))); _fileMenu.add(createMenuItem(_I("menuFileExport"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, InputEvent.SHIFT_MASK | scMask), new FileAction(FileAction.EXPORT))); jmi = _fileMenu.add( createMenuItem(_I("menuFileCloseTab"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, scMask), new FileAction(FileAction.CLOSE_TAB))); jmi.setName("CLOSE_TAB"); if (showPrefs) { _fileMenu.addSeparator(); _fileMenu.add(createMenuItem(_I("menuFilePreferences"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, scMask), new FileAction(FileAction.PREFERENCES))); } if (showQuit) { _fileMenu.addSeparator(); _fileMenu.add(createMenuItem(_I("menuFileQuit"), null, new FileAction(FileAction.QUIT))); } }
From source file:haven.GameUI.java
public boolean globtype(char key, KeyEvent ev) { if (key == ':') { entercmd();/*from w w w .j av a2 s.co m*/ return (true); } else if (key == ' ') { toggleui(); return (true); } else if (key == 3) { if (chat.visible && !chat.hasfocus) { setfocus(chat); } else { if (chat.sz.y == 0) { chat.resize(chat.savedw, chat.savedh); setfocus(chat); } else { chat.resize(0, 0); } } Utils.setprefb("chatvis", chat.sz.y != 0); } else if (key == 16) { /* if((polity != null) && polity.show(!polity.visible)) { polity.raise(); fitwdg(polity); setfocus(polity); } */ return (true); } else if ((key == 27) && (map != null) && !map.hasfocus) { setfocus(map); return (true); } else if (key != 0) { boolean alt = ev.isAltDown(); boolean ctrl = ev.isControlDown(); boolean shift = ev.isShiftDown(); int keycode = ev.getKeyCode(); if (alt && keycode >= KeyEvent.VK_0 && keycode <= KeyEvent.VK_9) { beltwdg.setCurrentBelt(Utils.floormod(keycode - KeyEvent.VK_0 - 1, 10)); return true; } else if (alt && keycode == KeyEvent.VK_S) { studywnd.show(!studywnd.visible); if (studywnd.visible) studywnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_M) { if (mmapwnd != null) { mmapwnd.togglefold(); return true; } } else if (alt && keycode == KeyEvent.VK_C) { craftwnd.show(!craftwnd.visible); if (craftwnd.visible) craftwnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_B) { buildwnd.toggle(); if (buildwnd.visible) buildwnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_N) { Config.nightvision.set(!Config.nightvision.get()); } else if (alt && keycode == KeyEvent.VK_G) { if (map != null) map.gridOverlay.setVisible(!map.gridOverlay.isVisible()); return true; } else if (alt && keycode == KeyEvent.VK_R) { if (mmap != null) mmap.toggleCustomIcons(); return true; } else if (alt && keycode == KeyEvent.VK_D) { if (map != null) map.toggleGobRadius(); return true; } else if (alt && keycode == KeyEvent.VK_Q) { Config.showQuality.set(!Config.showQuality.get()); return true; } else if (alt && keycode == KeyEvent.VK_K) { deckwnd.show(!deckwnd.visible); deckwnd.c = new Coord(sz.sub(deckwnd.sz).div(2)); if (deckwnd.visible) deckwnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_F) { if (map != null) { map.toggleFriendlyFire(); msg("Friendly fire prevention is now turned " + (map.isPreventFriendlyFireEnabled() ? "on" : "off")); } return true; } else if (alt && keycode == KeyEvent.VK_I) { Config.showGobInfo.set(!Config.showGobInfo.get()); return true; } else if (alt && keycode == KeyEvent.VK_W) { Config.screenshotMode = !Config.screenshotMode; return true; } else if (alt && keycode == KeyEvent.VK_T) { Config.disableTileTransitions.set(!Config.disableTileTransitions.get()); ui.sess.glob.map.rebuild(); return true; } else if (keycode == KeyEvent.VK_Q && ev.getModifiers() == 0) { /* // get all forageables from config List<String> names = new ArrayList<String>(); for (CustomIconGroup group : ui.sess.glob.icons.config.groups) { if ("Forageables".equals(group.name)) { for (CustomIconMatch match : group.matches) if (match.show) names.add(match.value); break; } } tasks.add(new Forager(11 * Config.autopickRadius.get(), 1, names.toArray(new String[names.size()]))); */ ContextTaskFinder.checkForageables(tasks, ui); return true; } else if (keycode == KeyEvent.VK_E && ev.getModifiers() == 0) { ContextTaskFinder.findHandTask(tasks, ui); return true; } else if (keycode == KeyEvent.VK_F && ev.getModifiers() == 0) { ContextTaskFinder.findBuilding(tasks, ui); return true; } else if (keycode >= KeyEvent.VK_NUMPAD1 && keycode <= KeyEvent.VK_NUMPAD4) { tasks.add(new MileStoneTask(Utils.floormod(keycode - KeyEvent.VK_NUMPAD0 - 1, 10))); return true; } else if (keycode == KeyEvent.VK_W && ev.getModifiers() == 0) { tasks.add(new Drunkard()); return true; } else if (shift && keycode == KeyEvent.VK_I) { Config.hideKinInfoForNonPlayers.set(!Config.hideKinInfoForNonPlayers.get()); return true; } else if (ctrl && keycode == KeyEvent.VK_H) { Config.hideModeEnabled.set(!Config.hideModeEnabled.get()); return true; } else if (alt && keycode == KeyEvent.VK_P) { Config.showGobPaths.set(!Config.showGobPaths.get()); return true; } else if (shift && keycode == KeyEvent.VK_W) { if (Config.showQualityMode.get() == 1) { Config.showQualityMode.set(2); } else { Config.showQualityMode.set(1); } return true; } else if (keycode == KeyEvent.VK_TAB && Config.agroclosest.get()) { if (map != null) map.aggroclosest(); return true; } else if (ctrl && keycode == KeyEvent.VK_F) { Config.displayFPS.set(!Config.displayFPS.get()); return true; } else if (keycode == KeyEvent.VK_Z && ev.getModifiers() == 0) { tasks.killAllTasks(); return true; } else if (keycode == 192 && ev.getModifiers() == 0) { getparent(GameUI.class).menu.wdgmsg("act", "travel", "hearth"); return true; } else if (shift && keycode == KeyEvent.VK_S) { HavenPanel.screenshot = true; return true; } } return (super.globtype(key, ev)); }
From source file:org.jab.docsearch.DocSearch.java
/** * Creates menu bar//from ww w . j a va2s. c o m * * @param menuBar Menu bar */ private JMenuBar createMenuBar() { // menu bar JMenuBar menuBar = new JMenuBar(); // ----- menu file // menu item print JMenuItem menuItemPrint = new JMenuItem(I18n.getString("menuitem.print")); menuItemPrint.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.CTRL_MASK)); menuItemPrint.setActionCommand("ac_print"); menuItemPrint.addActionListener(this); // scale X JRadioButtonMenuItem scaleXRadioBut = new JRadioButtonMenuItem(I18n.getString("print_scale_width")); scaleXRadioBut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, Event.CTRL_MASK)); scaleXRadioBut.addActionListener(new ScaleXListener()); // scale Y JRadioButtonMenuItem scaleYRadioBut = new JRadioButtonMenuItem(I18n.getString("print_scale_length")); scaleYRadioBut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)); scaleYRadioBut.addActionListener(new ScaleYListener()); // scale fit JRadioButtonMenuItem scaleFitRadioBut = new JRadioButtonMenuItem(I18n.getString("print_scale_to_fit")); scaleFitRadioBut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK)); scaleFitRadioBut.addActionListener(new ScaleFitListener()); // scale half JRadioButtonMenuItem scaleHalfRadioBut = new JRadioButtonMenuItem(I18n.getString("print_scale_half")); scaleHalfRadioBut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, Event.CTRL_MASK)); scaleHalfRadioBut.addActionListener(new ScaleHalfListener()); // scale double JRadioButtonMenuItem scale2RadioBut = new JRadioButtonMenuItem(I18n.getString("print_scale_2x")); scale2RadioBut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK)); scale2RadioBut.addActionListener(new Scale2Listener()); // scale off JRadioButtonMenuItem scaleOffRadioBut = new JRadioButtonMenuItem(I18n.getString("print_scale_off"), true); scaleOffRadioBut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK)); ButtonGroup scaleSetGroup = new ButtonGroup(); scaleSetGroup.add(scale2RadioBut); scaleSetGroup.add(scaleFitRadioBut); scaleSetGroup.add(scaleHalfRadioBut); scaleSetGroup.add(scaleOffRadioBut); scaleSetGroup.add(scaleXRadioBut); scaleSetGroup.add(scaleYRadioBut); // build complete menu print preferences JMenu menuPrintPref = new JMenu(I18n.getString("menuitem.print_preferences"), true); menuPrintPref.add(scaleXRadioBut); menuPrintPref.add(scaleYRadioBut); menuPrintPref.add(scaleFitRadioBut); menuPrintPref.add(scaleHalfRadioBut); menuPrintPref.add(scale2RadioBut); menuPrintPref.addSeparator(); menuPrintPref.add(scaleOffRadioBut); // menu item exit JMenuItem menuItemExit = new JMenuItem(I18n.getString("menuitem.exit")); menuItemExit.setActionCommand("ac_exit"); menuItemExit.addActionListener(this); // build complete menu file JMenu menuFile = new JMenu(I18n.getString("menu.file")); menuFile.add(menuItemPrint); menuFile.add(menuPrintPref); menuFile.addSeparator(); menuFile.add(menuItemExit); // add menu to menu bar menuBar.add(menuFile); // ----- menu index // menu item new JMenuItem menuItemNewIndex = new JMenuItem(I18n.getString("menuitem.new_index")); menuItemNewIndex.setActionCommand("ac_newindex"); menuItemNewIndex.addActionListener(this); // menu item new spider JMenuItem menuItemNewSpiderIndex = new JMenuItem(I18n.getString("menuitem.new_spider_index")); menuItemNewSpiderIndex.setActionCommand("ac_newspiderindex"); menuItemNewSpiderIndex.addActionListener(this); // menu item manage JMenuItem menuItemManageIndex = new JMenuItem(I18n.getString("menuitem.manage_indexes")); menuItemManageIndex.setActionCommand("ac_manageindex"); menuItemManageIndex.addActionListener(this); // menu item rebuild JMenuItem menuItemRebuildIndex = new JMenuItem(I18n.getString("menuitem.rebuild_all_indexes")); menuItemRebuildIndex.setActionCommand("ac_rebuildindexes"); menuItemRebuildIndex.addActionListener(this); // menu item import JMenuItem menuItemImportIndex = new JMenuItem(I18n.getString("menuitem.import_index")); menuItemImportIndex.setActionCommand("ac_importindex"); menuItemImportIndex.addActionListener(this); // build complete menu index JMenu indexMenu = new JMenu(I18n.getString("menu.index")); indexMenu.add(menuItemNewIndex); indexMenu.add(menuItemNewSpiderIndex); indexMenu.add(menuItemManageIndex); indexMenu.add(menuItemRebuildIndex); indexMenu.addSeparator(); indexMenu.add(menuItemImportIndex); // add menu to menu bar menuBar.add(indexMenu); // ----- menu bookmark // menu item add JMenuItem menuItemAddBookmark = new JMenuItem(I18n.getString("menuitem.add_bookmark")); menuItemAddBookmark.setActionCommand("ac_addbookmark"); menuItemAddBookmark.addActionListener(this); // menu item delete all JMenuItem menuItemDeleteAll = new JMenuItem(I18n.getString("menuitem.delete_all_bookmarks")); menuItemDeleteAll.setActionCommand("ac_deleteallbookmarks"); menuItemDeleteAll.addActionListener(this); // build complete menu index bookMarkMenu = new JMenu(I18n.getString("menu.bookmarks")); bookMarkMenu.add(menuItemAddBookmark); bookMarkMenu.add(menuItemDeleteAll); bookMarkMenu.addSeparator(); // add menu to menu bar menuBar.add(bookMarkMenu); // ----- menu report // menu item metadata report JMenuItem menuItemMetadataReport = new JMenuItem(I18n.getString("menuitem.metadata_report")); menuItemMetadataReport.setActionCommand("ac_metadata_report"); menuItemMetadataReport.addActionListener(this); // menu item servlet report JMenuItem menuItemServletReport = new JMenuItem(I18n.getString("menuitem.servlet_log_report")); menuItemServletReport.setActionCommand("ac_servlet_log_report"); menuItemServletReport.addActionListener(this); // build complete menu report JMenu reportMenu = new JMenu(I18n.getString("menu.reports")); reportMenu.add(menuItemMetadataReport); reportMenu.add(menuItemServletReport); // add menu to menu bar menuBar.add(reportMenu); // ----- menu tools // menu item makr cd JMenuItem menuItemMakeCD = new JMenuItem(I18n.getString("menuitem.make_cd")); menuItemMakeCD.setActionCommand("ac_makecd"); menuItemMakeCD.addActionListener(this); // menu item setting JMenuItem menuItemSetting = new JMenuItem(I18n.getString("menuitem.settings")); menuItemSetting.setActionCommand("ac_settings"); menuItemSetting.addActionListener(this); // build complete menu report JMenu menuTool = new JMenu(I18n.getString("menu.tools")); menuTool.add(menuItemMakeCD); menuTool.addSeparator(); menuTool.add(menuItemSetting); // add menu to menu bar menuBar.add(menuTool); // ----- menu help // menu item search tip JMenuItem menuItemSearchTip = new JMenuItem(I18n.getString("menuitem.search_tips")); menuItemSearchTip.setActionCommand("ac_search_tips"); menuItemSearchTip.addActionListener(this); // menu item about JMenuItem menuItemAbout = new JMenuItem(I18n.getString("menuitem.about")); menuItemAbout.setActionCommand("ac_about"); menuItemAbout.addActionListener(this); // build complete menu help JMenu menuHelp = new JMenu(I18n.getString("menu.help")); menuHelp.add(menuItemSearchTip); menuHelp.add(menuItemAbout); // add menu to menu bar menuBar.add(menuHelp); // finished return menuBar; }
From source file:com.opendoorlogistics.studio.AppFrame.java
@SuppressWarnings("serial") private List<MyAction> initFileActions() { ArrayList<MyAction> ret = new ArrayList<>(); ret.add(new MyAction("New", "Create new file", null, "document-new-6.png", false, KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK)) { @Override//from w w w .j ava2 s . c om public void actionPerformed(ActionEvent e) { createNewDatastore(); } }); ret.add(new MyAction("Open", "Open file", null, "document-open-3.png", false, KeyStroke.getKeyStroke(KeyEvent.VK_O, java.awt.Event.CTRL_MASK)) { @Override public void actionPerformed(ActionEvent e) { openDatastoreWithUserPrompt(); } }); ret.add(null); ret.add(new MyAction("Close", "Close file", null, "document-close-4.png", true, KeyStroke.getKeyStroke(KeyEvent.VK_W, java.awt.Event.CTRL_MASK)) { @Override public void actionPerformed(ActionEvent e) { if (!canCloseDatastore()) { return; } closeDatastore(); } }); ret.add(null); ret.add(new MyAction("Save", "Save file", null, "document-save-2.png", true, KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)) { @Override public void actionPerformed(ActionEvent e) { saveDatastoreWithoutUserPrompt(loaded.getLastFile()); } @Override public void updateEnabled() { setEnabled(loaded != null && loaded.getLastFile() != null); } }); ret.add(new MyAction("Save as", "Save file as", null, "document-save-as-2.png", true, KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK | Event.ALT_MASK)) { @Override public void actionPerformed(ActionEvent e) { JFileChooser chooser = SupportedFileType.EXCEL.createFileChooser(); if (loaded.getLastFile() != null) { chooser.setSelectedFile(loaded.getLastFile()); } else { File file = PreferencesManager.getSingleton().getFile(PrefKey.LAST_IO_DIR); IOUtils.setFile(file, chooser); } if (chooser.showSaveDialog(AppFrame.this) == JFileChooser.APPROVE_OPTION) { saveDatastoreWithoutUserPrompt(chooser.getSelectedFile()); } } }); return ret; }