List of usage examples for java.awt.event KeyEvent VK_T
int VK_T
To view the source code for java.awt.event KeyEvent VK_T.
Click Source Link
From source file:jchrest.gui.Shell.java
private JMenu createShellMenu() { JMenuItem exit = new JMenuItem("Exit", new ImageIcon(Shell.class.getResource("icons/Stop16.gif"))); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0);//w w w .j av a 2 s. co m } }); JMenu menu = new JMenu("Shell"); menu.setMnemonic(KeyEvent.VK_S); menu.add(new AboutAction(this)); menu.getItem(0).setMnemonic(KeyEvent.VK_A); menu.add(new LookFeelAction(this)); menu.getItem(1).setMnemonic(KeyEvent.VK_T); menu.add(new JSeparator()); menu.add(exit); menu.getItem(3).setMnemonic(KeyEvent.VK_X); menu.getItem(0).setAccelerator(KeyStroke.getKeyStroke('A', java.awt.Event.CTRL_MASK, false)); menu.getItem(3).setAccelerator(KeyStroke.getKeyStroke('X', java.awt.Event.CTRL_MASK, false)); return menu; }
From source file:org.f2o.absurdum.puck.gui.PuckFrame.java
/** * Instances and shows Puck's main frame. *//* w w w.j av a 2 s . c o m*/ public PuckFrame() { super(); setLookAndFeel(PuckConfiguration.getInstance().getProperty("look")); /* LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels(); for ( int i = 0 ; i < lfs.length ; i++ ) { if ( lfs[i].getName().toLowerCase().contains("nimbus") ) { try { UIManager.setLookAndFeel(lfs[i].getClassName()); } catch (Exception e) //class not found, instantiation exception, etc. (shouldn't happen) { e.printStackTrace(); } } } */ setSize(PuckConfiguration.getInstance().getIntegerProperty("windowWidth"), PuckConfiguration.getInstance().getIntegerProperty("windowHeight")); setLocation(PuckConfiguration.getInstance().getIntegerProperty("windowLocationX"), PuckConfiguration.getInstance().getIntegerProperty("windowLocationY")); //setSize(600,600); if (PuckConfiguration.getInstance().getBooleanProperty("windowMaximized")) maximizeIfPossible(); //setTitle(Messages.getInstance().getMessage("frame.title")); refreshTitle(); left = new JPanel(); right = new JPanel(); JScrollPane rightScroll = new JScrollPane(right); rightScroll.getVerticalScrollBar().setUnitIncrement(16); //faster scrollbar (by default it was very slow, maybe because component inside is not text component!) split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, rightScroll) { //dynamic resizing of right panel /* public void setDividerLocation ( int pixels ) { if ( propPanel != null ) { double rightPartSize = getContentPane().getWidth() - pixels - 15; System.out.println("rps=" + rightPartSize); System.out.println("mnw=" + this.getMinimumSize().getWidth()); Dimension propPanSize = propPanel.getSize(); int propPanHeight = 0; if (propPanSize != null) propPanHeight = (int) propPanSize.getHeight(); //propPanel.revalidate(); System.out.println("h " + propPanHeight); //if ( rightPartSize >= propPanel.getMinimumSize().getWidth() ) propPanel.setPreferredSize(new Dimension((int)rightPartSize,propPanHeight)); //propPanel.setMinimumSize(new Dimension((int)rightPartSize,propPanHeight)); //propPanel.setMaximumSize(new Dimension((int)rightPartSize,propPanHeight)); //propPanel.setSize(new Dimension((int)rightPartSize,propPanHeight)); propPanel.revalidate(); } super.setDividerLocation(pixels); } */ }; split.setContinuousLayout(true); split.setResizeWeight(0.60); final int dividerLoc = PuckConfiguration.getInstance().getIntegerProperty("dividerLocation", 0); /* SwingUtilities.invokeLater(new Runnable(){ public void run() { */ /* } }); */ split.setOneTouchExpandable(true); getContentPane().add(split); System.out.println(Toolkit.getDefaultToolkit().getBestCursorSize(20, 20)); //it's 32x32. Will have to do it. //Image img = Toolkit.getDefaultToolkit().createImage( getClass().getResource("addCursor32.png") ); //Image img = Toolkit.getDefaultToolkit().createImage("addCursor32.png"); left.setLayout(new BorderLayout()); //right.setLayout(new BoxLayout(right,BoxLayout.LINE_AXIS)); if (PuckConfiguration.getInstance().getBooleanProperty("dynamicFormResizing")) right.setLayout(new BorderLayout()); else right.setLayout(new FlowLayout()); propPanel = new PropertiesPanel(); right.add(propPanel); graphPanel = new GraphEditingPanel(propPanel); graphPanel.setGrid(Boolean.valueOf(PuckConfiguration.getInstance().getProperty("showGrid")).booleanValue()); graphPanel.setSnapToGrid( Boolean.valueOf(PuckConfiguration.getInstance().getProperty("snapToGrid")).booleanValue()); propPanel.setGraphEditingPanel(graphPanel); tools = new PuckToolBar(graphPanel, propPanel, this); left.add(tools, BorderLayout.WEST); left.add(graphPanel, BorderLayout.CENTER); /* Action testAction = new AbstractAction() { public void actionPerformed ( ActionEvent evt ) { System.out.println("Puck!"); } } ; testAction.putValue(Action.NAME,"Print Puck"); tools.add(testAction); */ /* public void saveChanges ( ) { if ( editingFileName == null ) { //save as... code } else { File f = new File(editingFileName); try { Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d)); Transformer t = TransformerFactory.newInstance().newTransformer(); Source s = new DOMSource(d); Result r = new StreamResult(f); t.transform(s,r); editingFileName = f.toString(); refreshTitle(); } catch ( Exception e ) { JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } } */ JMenuBar mainMenuBar = new JMenuBar(); JMenu fileMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file")); fileMenu.setMnemonic(KeyEvent.VK_F); saveMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.save")); saveMenuItem.setMnemonic(KeyEvent.VK_S); saveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (editingFileName == null) JOptionPane.showMessageDialog(PuckFrame.this, "File has no name!", "Whoops!", JOptionPane.ERROR_MESSAGE); /* File f = new File(editingFileName); try { Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d)); Transformer t = TransformerFactory.newInstance().newTransformer(); Source s = new DOMSource(d); Result r = new StreamResult(f); t.transform(s,r); editingFileName = f.toString(); refreshTitle(); } catch ( Exception e ) { JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } */ try { saveChangesInCurrentFile(); } catch (Exception e) { JOptionPane.showMessageDialog(PuckFrame.this, e.getLocalizedMessage(), "Whoops!", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } }); JMenu newMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.new")); JMenuItem newBlankMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.new.blank")); //newBlankMenuItem.setMnemonic(KeyEvent.VK_N); newBlankMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { GraphElementPanel.emptyQueue(); //stop deferred loads graphPanel.clear(); propPanel.clear(); JSyntaxBSHCodeFrame.closeAllInstances(); WorldPanel wp = new WorldPanel(graphPanel); WorldNode wn = new WorldNode(wp); graphPanel.setWorldNode(wn); propPanel.show(graphPanel.getWorldNode()); resetCurrentlyEditingFile(); refreshTitle(); //revalidate(); //only since java 1.7 //invalidate(); //validate(); split.revalidate(); //JComponents do have it before java 1.7 (not JFrame) } }); newMenu.add(newBlankMenuItem); JMenu templateMenus = new WorldTemplateMenuBuilder(this).getMenu(); if (templateMenus != null) { for (int i = 0; i < templateMenus.getItemCount(); i++) { if (i == 0) newMenu.add(new JSeparator()); newMenu.add(templateMenus.getItem(i)); } } JMenuItem saveAsMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.saveas")); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { /* JFileChooser jfc = new JFileChooser("."); int opt = jfc.showSaveDialog(PuckFrame.this); if ( opt == JFileChooser.APPROVE_OPTION ) { File f = jfc.getSelectedFile(); try { Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d)); Transformer t = TransformerFactory.newInstance().newTransformer(); Source s = new DOMSource(d); Result r = new StreamResult(f); t.transform(s,r); editingFileName = f.toString(); saveMenuItem.setEnabled(true); refreshTitle(); } catch ( Exception e ) { JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } */ try { saveAs(); saveMenuItem.setEnabled(true); } catch (Exception e) { JOptionPane.showMessageDialog(PuckFrame.this, e.getLocalizedMessage(), "Whoops!", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } //saveAs(saveMenuItem); } }); JMenuItem openMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.open")); openMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //graphPanel.setVisible(false); //propPanel.setVisible(false); JFileChooser jfc = new JFileChooser("."); jfc.setFileFilter(new FiltroFicheroMundo()); int opt = jfc.showOpenDialog(PuckFrame.this); if (opt == JFileChooser.APPROVE_OPTION) { File f = jfc.getSelectedFile(); openFileOrShowError(f); } //graphPanel.setVisible(true); //propPanel.setVisible(true); } }); openRecentMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.recent")); JMenuItem exitMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.exit")); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { /* int opt = JOptionPane.showConfirmDialog(PuckFrame.this,Messages.getInstance().getMessage("exit.sure.text"),Messages.getInstance().getMessage("exit.sure.title"),JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE); if ( opt == JOptionPane.YES_OPTION ) System.exit(0); */ userExit(); } }); JMenu exportMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.export")); JMenuItem exportAppletMenuItem = new JMenuItem( UIMessages.getInstance().getMessage("menu.file.export.applet")); exportAppletMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ExportAppletDialog dial = new ExportAppletDialog(PuckFrame.this); dial.setVisible(true); } }); exportMenu.add(exportAppletMenuItem); fileMenu.add(newMenu); fileMenu.add(openMenuItem); fileMenu.add(openRecentMenu); updateRecentMenu(); fileMenu.add(new JSeparator()); saveMenuItem.setEnabled(false); fileMenu.add(saveMenuItem); fileMenu.add(saveAsMenuItem); fileMenu.add(exportMenu); fileMenu.add(new JSeparator()); fileMenu.add(exitMenuItem); mainMenuBar.add(fileMenu); /** * Create an Edit menu to support cut/copy/paste. */ JMenu editMenu = new JMenu(UIMessages.getInstance().getMessage("menu.edit")); editMenu.setMnemonic(KeyEvent.VK_E); JMenuItem findMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.find.entity")); findMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showFindEntityDialog(); } }); editMenu.add(findMenuItem); editMenu.add(new JSeparator()); JMenuItem aMenuItem = new JMenuItem(new CutAction()); aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.cut")); aMenuItem.setMnemonic(KeyEvent.VK_T); editMenu.add(aMenuItem); aMenuItem = new JMenuItem(new CopyAction()); aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.copy")); aMenuItem.setMnemonic(KeyEvent.VK_C); editMenu.add(aMenuItem); aMenuItem = new JMenuItem(new PasteAction()); aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.paste")); aMenuItem.setMnemonic(KeyEvent.VK_P); editMenu.add(aMenuItem); mainMenuBar.add(editMenu); JMenu optionsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options")); JMenu gridMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options.grid")); optionsMenu.add(gridMenu); final JCheckBoxMenuItem showGridItem = new JCheckBoxMenuItem( UIMessages.getInstance().getMessage("menu.options.grid.show")); showGridItem.setSelected( Boolean.valueOf(PuckConfiguration.getInstance().getProperty("showGrid")).booleanValue()); gridMenu.add(showGridItem); showGridItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { graphPanel.setGrid(true); PuckConfiguration.getInstance().setProperty("showGrid", "true"); } else if (e.getStateChange() == ItemEvent.DESELECTED) { graphPanel.setGrid(false); PuckConfiguration.getInstance().setProperty("showGrid", "false"); } graphPanel.repaint(); } }); final JCheckBoxMenuItem snapToGridItem = new JCheckBoxMenuItem( UIMessages.getInstance().getMessage("menu.options.grid.snap")); snapToGridItem.setSelected( Boolean.valueOf(PuckConfiguration.getInstance().getProperty("snapToGrid")).booleanValue()); gridMenu.add(snapToGridItem); snapToGridItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { graphPanel.setSnapToGrid(true); PuckConfiguration.getInstance().setProperty("snapToGrid", "true"); } else if (e.getStateChange() == ItemEvent.DESELECTED) { graphPanel.setSnapToGrid(false); PuckConfiguration.getInstance().setProperty("snapToGrid", "false"); } graphPanel.repaint(); } }); JMenuItem translationModeMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options.translation")); ButtonGroup translationGroup = new ButtonGroup(); final JRadioButtonMenuItem holdMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.translation.hold")); final JRadioButtonMenuItem pushMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.translation.push")); pushMenuItem.setSelected("push".equals(PuckConfiguration.getInstance().getProperty("translateMode"))); if (!pushMenuItem.isSelected()) holdMenuItem.setSelected(true); translationGroup.add(holdMenuItem); translationGroup.add(pushMenuItem); holdMenuItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { if (holdMenuItem.isSelected()) PuckConfiguration.getInstance().setProperty("translateMode", "hold"); else PuckConfiguration.getInstance().setProperty("translateMode", "push"); } }); translationModeMenu.add(holdMenuItem); translationModeMenu.add(pushMenuItem); optionsMenu.add(translationModeMenu); JMenuItem toolSelectionModeMenu = new JMenu( UIMessages.getInstance().getMessage("menu.options.toolselection")); ButtonGroup toolSelectionGroup = new ButtonGroup(); final JRadioButtonMenuItem oneUseMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.toolselection.oneuse")); final JRadioButtonMenuItem multipleUseMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.toolselection.multipleuse")); multipleUseMenuItem.setSelected( "multipleUse".equalsIgnoreCase(PuckConfiguration.getInstance().getProperty("toolSelectionMode"))); if (!multipleUseMenuItem.isSelected()) oneUseMenuItem.setSelected(true); toolSelectionGroup.add(oneUseMenuItem); toolSelectionGroup.add(multipleUseMenuItem); oneUseMenuItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { if (oneUseMenuItem.isSelected()) PuckConfiguration.getInstance().setProperty("toolSelectionMode", "oneUse"); else PuckConfiguration.getInstance().setProperty("toolSelectionMode", "multipleUse"); } }); toolSelectionModeMenu.add(oneUseMenuItem); toolSelectionModeMenu.add(multipleUseMenuItem); optionsMenu.add(toolSelectionModeMenu); JMenuItem sizesMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.iconsizes")); sizesMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { IconSizesDialog dial = new IconSizesDialog(PuckFrame.this, true); dial.setVisible(true); } }); optionsMenu.add(sizesMenuItem); JMenuItem showHideMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.showhide")); showHideMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ShowHideDialog dial = new ShowHideDialog(PuckFrame.this, true); dial.setVisible(true); } }); optionsMenu.add(showHideMenuItem); JMenuItem mapColorsMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.mapcolors")); mapColorsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MapColorsDialog dial = new MapColorsDialog(PuckFrame.this, true); dial.setVisible(true); } }); optionsMenu.add(mapColorsMenuItem); String skinList = PuckConfiguration.getInstance().getProperty("availableSkins"); if (skinList != null && skinList.trim().length() > 0) { JMenu skinsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.skins")); StringTokenizer st = new StringTokenizer(skinList, ", "); ButtonGroup skinButtons = new ButtonGroup(); while (st.hasMoreTokens()) { final String nextSkin = st.nextToken(); final JRadioButtonMenuItem skinMenuItem = new JRadioButtonMenuItem(nextSkin); skinMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setSkin(nextSkin); skinMenuItem.setSelected(true); } }); if (nextSkin.equals(PuckConfiguration.getInstance().getProperty("skin"))) skinMenuItem.setSelected(true); skinsMenu.add(skinMenuItem); skinButtons.add(skinMenuItem); } optionsMenu.add(skinsMenu); } JMenu lookFeelMenu = new JMenu(UIMessages.getInstance().getMessage("menu.looks")); ButtonGroup lookButtons = new ButtonGroup(); final JRadioButtonMenuItem defaultLookMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.looks.default")); if ("default".equals(PuckConfiguration.getInstance().getProperty("look"))) { defaultLookMenuItem.setSelected(true); } lookFeelMenu.add(defaultLookMenuItem); lookButtons.add(defaultLookMenuItem); defaultLookMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel("default"); defaultLookMenuItem.setSelected(true); } }); final JRadioButtonMenuItem systemLookMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.looks.system")); if ("system".equals(PuckConfiguration.getInstance().getProperty("look"))) { systemLookMenuItem.setSelected(true); } lookFeelMenu.add(systemLookMenuItem); lookButtons.add(systemLookMenuItem); systemLookMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel("system"); systemLookMenuItem.setSelected(true); } }); String additionalLookList = PuckConfiguration.getInstance().getProperty("additionalLooks"); if (additionalLookList != null && additionalLookList.trim().length() > 0) { StringTokenizer st = new StringTokenizer(additionalLookList, ", "); while (st.hasMoreTokens()) { final String nextLook = st.nextToken(); final JRadioButtonMenuItem lookMenuItem = new JRadioButtonMenuItem(nextLook); lookMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel(nextLook); lookMenuItem.setSelected(true); } }); if (nextLook.equals(PuckConfiguration.getInstance().getProperty("look"))) { lookMenuItem.setSelected(true); } lookFeelMenu.add(lookMenuItem); lookButtons.add(lookMenuItem); } } optionsMenu.add(lookFeelMenu); optionsMenu.add(new UILanguageSelectionMenu(this)); mainMenuBar.add(optionsMenu); JMenu toolsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.tools")); final JMenuItem verbListMenuItem = new JMenuItem( UIMessages.getInstance().getMessage("menu.tools.verblist")); verbListMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { WorldPanel wp = (WorldPanel) graphPanel.getWorldNode().getAssociatedPanel(); VerbListFrame vlf = VerbListFrame.getInstance(wp.getSelectedLanguageCode()); vlf.setVisible(true); } }); toolsMenu.add(verbListMenuItem); final JMenuItem validateMenuItem = new JMenuItem( UIMessages.getInstance().getMessage("menu.tools.validatebsh")); validateMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { BeanShellCodeValidator bscv = new BeanShellCodeValidator(graphPanel); if (!bscv.validate()) { BeanShellErrorsDialog bsed = new BeanShellErrorsDialog(PuckFrame.this, bscv.getErrorText()); bsed.setVisible(true); //JOptionPane.showMessageDialog(PuckFrame.this, bscv.getErrorText()); } else { JOptionPane.showMessageDialog(PuckFrame.this, UIMessages.getInstance().getMessage("bsh.code.ok"), "OK!", JOptionPane.INFORMATION_MESSAGE); //JOptionPane.showMessageDialog(PuckFrame.this, bscv.getErrorText()); } } }); toolsMenu.add(validateMenuItem); mainMenuBar.add(toolsMenu); JMenu helpMenu = new JMenu(UIMessages.getInstance().getMessage("menu.help")); //JHelpAction.startHelpWorker("help/PUCKHelp.hs"); //JHelpAction helpTocAction = JHelpAction.getShowHelpInstance(Messages.getInstance().getMessage("menu.help.toc")); //JHelpAction helpContextSensitiveAction = JHelpAction.getTrackInstance(Messages.getInstance().getMessage("menu.help.context")); //final JMenuItem helpTocMenuItem = new JMenuItem(helpTocAction); //final JMenuItem helpContextSensitiveMenuItem = new JMenuItem(helpContextSensitiveAction); //helpMenu.add(helpTocMenuItem); //helpMenu.add(helpContextSensitiveMenuItem); final JMenuItem helpMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.help.toc")); helpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DocumentationLinkDialog dial = new DocumentationLinkDialog(PuckFrame.this, true); dial.setVisible(true); } }); helpMenu.add(helpMenuItem); mainMenuBar.add(helpMenu); MenuMnemonicOnTheFly.setMnemonics(mainMenuBar); this.setJMenuBar(mainMenuBar); //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { userExit(); } }); propPanel.show(graphPanel.getWorldNode()); setVisible(true); SwingUtilities.invokeLater(new Runnable() { public void run() { if (dividerLoc > 0) split.setDividerLocation(dividerLoc); else split.setDividerLocation(0.60); } }); }
From source file:haven.GameUI.java
public boolean globtype(char key, KeyEvent ev) { if (key == ':') { entercmd();/*from w ww . j a v a 2 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:lejos.pc.charting.LogChartFrame.java
/** All the setup of components, etc. What's scary is Swing is a "lightweight" GUI framework... * @throws Exception/* w w w . ja v a2 s . c o m*/ */ private void jbInit() throws Exception { this.setJMenuBar(menuBar); this.setSize(new Dimension(819, 613)); this.setMinimumSize(new Dimension(819, 613)); this.setTitle("NXT Charting Logger"); this.setEnabled(true); // enforce minimum window size this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { JFrame theFrame = (JFrame) e.getSource(); Dimension d1 = theFrame.getMinimumSize(); Dimension d2 = theFrame.getSize(); boolean enforce = false; if (theFrame.getWidth() < d1.getWidth()) { d2.setSize(d1.getWidth(), d2.getHeight()); enforce = true; } if (theFrame.getHeight() < d1.getHeight()) { d2.setSize(d2.getWidth(), d1.getHeight()); enforce = true; } if (enforce) theFrame.setSize(d2); } }); this.getContentPane().setLayout(gridBagLayout1); MenuActionListener menuItemActionListener = new MenuActionListener(); MenuEventListener menuListener = new MenuEventListener(); menu = new JMenu("Edit"); menu.setMnemonic(KeyEvent.VK_E); menuBar.add(menu); menuItem = new JMenuItem("Copy Chart Image", KeyEvent.VK_I); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("Copy Data Log", KeyEvent.VK_D); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menu = new JMenu("View"); menu.setMnemonic(KeyEvent.VK_V); menu.setActionCommand("VIEW_MENU"); menu.addMenuListener(menuListener); menuBar.add(menu); menuItem = new JMenuItem("Expand Chart", KeyEvent.VK_F); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("Chart in New Window", KeyEvent.VK_N); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menu = new JMenu("Help"); menu.setMnemonic(KeyEvent.VK_H); menuBar.add(menu); menuItem = new JMenuItem("Chart controls", KeyEvent.VK_C); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("Generate sample data", KeyEvent.VK_G); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("About", KeyEvent.VK_A); menuItem.addActionListener(menuItemActionListener); jTabbedPane1.setPreferredSize(new Dimension(621, 199)); jTabbedPane1.setMinimumSize(new Dimension(621, 199)); menu.add(menuItem); jButtonConnect.setText("Connect"); jButtonConnect.setBounds(new Rectangle(25, 65, 115, 25)); jButtonConnect.setToolTipText("Connect/disconnect toggle"); jButtonConnect.setMnemonic('C'); jButtonConnect.setSelected(true); jButtonConnect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButtonConnect_actionPerformed(e); } }); UIPanel.setSize(new Dimension(820, 200)); UIPanel.setLayout(null); UIPanel.setPreferredSize(new Dimension(300, 200)); UIPanel.setMinimumSize(new Dimension(300, 200)); UIPanel.setBounds(new Rectangle(0, 350, 820, 200)); UIPanel.setMaximumSize(new Dimension(300, 32767)); connectionPanel.setBounds(new Rectangle(10, 10, 175, 100)); connectionPanel.setBorder(BorderFactory.createTitledBorder("Connection")); connectionPanel.setLayout(null); connectionPanel.setFont(new Font("Tahoma", 0, 11)); jLabel1logfilename.setText("Log File:"); jLabel1logfilename.setBounds(new Rectangle(10, 125, 165, 20)); jLabel1logfilename.setHorizontalTextPosition(SwingConstants.RIGHT); jLabel1logfilename.setHorizontalAlignment(SwingConstants.LEFT); jLabel1logfilename.setToolTipText("Specify the name of your log file here"); jTextFieldNXTName.setBounds(new Rectangle(5, 40, 165, 20)); jTextFieldNXTName.setToolTipText( "The name or Address of the NXT. Leave empty and the first one found will be used."); jTextFieldNXTName.requestFocus(); jTextAreaStatus.setLineWrap(true); jTextAreaStatus.setFont(new Font("Tahoma", 0, 11)); jTextAreaStatus.setWrapStyleWord(true); jTextAreaStatus.setBackground(SystemColor.window); dataLogTextArea.setLineWrap(false); dataLogTextArea.setFont(new Font("Tahoma", 0, 11)); dataLogTextArea.setBackground(SystemColor.window); FQPathTextArea.setBounds(new Rectangle(5, 170, 185, 40)); FQPathTextArea.setLineWrap(true); FQPathTextArea.setText(getCanonicalName(new File(".", ""))); FQPathTextArea.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); FQPathTextArea.setRows(2); FQPathTextArea.setFont(new Font("Tahoma", 0, 9)); FQPathTextArea.setOpaque(false); FQPathTextArea.setEditable(false); selectFolderButton.setText("Folder..."); selectFolderButton.setBounds(new Rectangle(120, 125, 70, 20)); selectFolderButton.setMargin(new Insets(1, 1, 1, 1)); selectFolderButton.setFocusable(false); selectFolderButton.setMnemonic('F'); selectFolderButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectFolderButton_actionPerformed(e); } }); // domain display limits GUI chartOptionsPanel.setLayout(null); chartDomLimitsPanel.setBounds(new Rectangle(5, 35, 180, 135)); chartDomLimitsPanel.setLayout(gridLayout1); chartDomLimitsPanel.setBorder(BorderFactory.createTitledBorder("Domain Display Limiting")); domainDisplayLimitSlider.setEnabled(false); domainDisplayLimitSlider.setMaximum(MAXDOMAIN_DATAPOINT_LIMIT); domainDisplayLimitSlider.setMinimum(MINDOMAIN_LIMIT); domainDisplayLimitSlider.setValue(MAXDOMAIN_DATAPOINT_LIMIT); domainDisplayLimitSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { domainDisplayLimitSlider_stateChanged(e); } }); useTimeRadioButton.setText("By Time"); useTimeRadioButton.setEnabled(false); useTimeRadioButton.setMnemonic('I'); useTimeRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { domainDisplayLimitRadioButton_actionPerformed(e); } }); useDataPointsRadioButton.setText("By Data Points"); ButtonGroup bg1 = new ButtonGroup(); bg1.add(useTimeRadioButton); bg1.add(useDataPointsRadioButton); useDataPointsRadioButton.setSelected(true); useDataPointsRadioButton.setEnabled(false); useDataPointsRadioButton.setMnemonic('P'); useDataPointsRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { domainDisplayLimitRadioButton_actionPerformed(e); } }); datasetLimitEnableCheckBox.setText("Enable"); datasetLimitEnableCheckBox.setRolloverEnabled(true); datasetLimitEnableCheckBox.setMnemonic('A'); datasetLimitEnableCheckBox.setToolTipText("Enable Domain Clipping"); datasetLimitEnableCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { datasetLimitEnableCheckBox_actionPerformed(e); } }); domainLimitLabel.setText(String.format("%1$,d datapoints", MAXDOMAIN_DATAPOINT_LIMIT).toString()); domainLimitLabel.setEnabled(false); gridLayout1.setRows(5); gridLayout1.setColumns(1); jLabel1.setText("Chart Title:"); jLabel1.setBounds(new Rectangle(200, 10, 85, 20)); jLabel1.setPreferredSize(new Dimension(115, 14)); jLabel2.setText("Range Axis 1 Label:"); jLabel2.setBounds(new Rectangle(200, 35, 115, 20)); jLabel2.setSize(new Dimension(115, 20)); jLabel3.setText("Range Axis 2 Label:"); jLabel3.setBounds(new Rectangle(200, 60, 115, 20)); jLabel3.setSize(new Dimension(115, 20)); jLabel4.setText("Range Axis 3 Label:"); jLabel4.setBounds(new Rectangle(200, 85, 115, 20)); jLabel4.setSize(new Dimension(115, 20)); jLabel6.setText("Range Axis 4 Label:"); jLabel6.setBounds(new Rectangle(200, 110, 115, 20)); jLabel6.setSize(new Dimension(115, 20)); titleLabelChangeNotifier notifier = new titleLabelChangeNotifier(); chartTitleTextField.setBounds(new Rectangle(315, 10, 290, 20)); chartTitleTextField.getDocument().addDocumentListener(notifier); axis1LabelTextField.setBounds(new Rectangle(315, 35, 290, 20)); axis1LabelTextField.getDocument().addDocumentListener(notifier); axis2LabelTextField.setBounds(new Rectangle(315, 60, 290, 20)); axis2LabelTextField.getDocument().addDocumentListener(notifier); axis3LabelTextField.setBounds(new Rectangle(315, 85, 290, 20)); axis3LabelTextField.getDocument().addDocumentListener(notifier); axis4LabelTextField.setBounds(new Rectangle(315, 110, 290, 20)); showCommentsCheckBox.setText("Show Comment Markers"); showCommentsCheckBox.setBounds(new Rectangle(200, 140, 185, 25)); showCommentsCheckBox.setToolTipText("Show/Hide any comment markers on the chart"); showCommentsCheckBox.setRolloverEnabled(true); showCommentsCheckBox.setSelected(true); showCommentsCheckBox.setMnemonic('M'); showCommentsCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { customChartPanel.setCommentsVisible(e.getStateChange() == ItemEvent.SELECTED); } }); scrollDomainCheckBox.setText("Scroll Domain"); scrollDomainCheckBox.setBounds(new Rectangle(10, 5, 175, 20)); scrollDomainCheckBox.setSize(new Dimension(175, 25)); scrollDomainCheckBox.setSelected(true); scrollDomainCheckBox.setMnemonic('O'); scrollDomainCheckBox.setToolTipText("Checked to scroll domain as new data is received"); scrollDomainCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scrollDomainCheckBox_actionPerformed(e); } }); axis4LabelTextField.getDocument().addDocumentListener(notifier); logFileTextField.setBounds(new Rectangle(10, 145, 180, 20)); logFileTextField.setText("NXTData.txt"); logFileTextField.setPreferredSize(new Dimension(180, 20)); logFileTextField.setToolTipText("File name. Leave empty to not log to file."); statusScrollPane.setOpaque(false); dataLogScrollPane.setOpaque(false); customChartPanel.setMinimumSize(new Dimension(400, 300)); customChartPanel.setPreferredSize(new Dimension(812, 400)); jLabel5.setText("NXT Name/Address:"); jLabel5.setBounds(new Rectangle(5, 20, 160, 20)); jLabel5.setToolTipText(jTextFieldNXTName.getToolTipText()); jLabel5.setHorizontalTextPosition(SwingConstants.RIGHT); jLabel5.setHorizontalAlignment(SwingConstants.LEFT); connectionPanel.add(jTextFieldNXTName, null); connectionPanel.add(jButtonConnect, null); connectionPanel.add(jLabel5, null); dataLogScrollPane.setViewportView(dataLogTextArea); jTabbedPane1.addTab("Data Log", dataLogScrollPane); statusScrollPane.setViewportView(jTextAreaStatus); jTabbedPane1.addTab("Status", statusScrollPane); jTabbedPane1.addTab("Chart", chartOptionsPanel); chartDomLimitsPanel.add(datasetLimitEnableCheckBox, null); chartDomLimitsPanel.add(useDataPointsRadioButton, null); chartDomLimitsPanel.add(useTimeRadioButton, null); chartDomLimitsPanel.add(domainDisplayLimitSlider, null); chartDomLimitsPanel.add(domainLimitLabel, null); chartOptionsPanel.add(scrollDomainCheckBox, null); chartOptionsPanel.add(showCommentsCheckBox, null); chartOptionsPanel.add(axis4LabelTextField, null); chartOptionsPanel.add(axis3LabelTextField, null); chartOptionsPanel.add(axis2LabelTextField, null); chartOptionsPanel.add(axis1LabelTextField, null); chartOptionsPanel.add(chartTitleTextField, null); chartOptionsPanel.add(jLabel6, null); chartOptionsPanel.add(jLabel4, null); chartOptionsPanel.add(jLabel3, null); chartOptionsPanel.add(jLabel2, null); chartOptionsPanel.add(jLabel1, null); chartOptionsPanel.add(chartDomLimitsPanel, null); tglbtnpauseplay = new JToggleButton(""); tglbtnpauseplay.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (lpm == null) return; boolean doPause = false; if (e.getStateChange() == ItemEvent.SELECTED) { doPause = true; } lpm.setReaderPaused(doPause); } }); // tglbtnpauseplay.addChangeListener(new ChangeListener() { // public void stateChanged(ChangeEvent e) { // System.out.println(e.toString()); // //lpm.setReaderPaused(doPause) // } // }); tglbtnpauseplay .setSelectedIcon(new ImageIcon(LogChartFrame.class.getResource("/lejos/pc/charting/play.png"))); tglbtnpauseplay.setIcon(new ImageIcon(LogChartFrame.class.getResource("/lejos/pc/charting/pause.png"))); tglbtnpauseplay.setBounds(571, 135, 30, 30); chartOptionsPanel.add(tglbtnpauseplay); jTabbedPane1.setToolTipTextAt(0, "The tab-delimited log of the data sent from the NXT"); jTabbedPane1.setToolTipTextAt(1, "Status output"); jTabbedPane1.setToolTipTextAt(2, "Chart options"); jTabbedPane1.setMnemonicAt(0, KeyEvent.VK_D); jTabbedPane1.setMnemonicAt(1, KeyEvent.VK_S); jTabbedPane1.setMnemonicAt(2, KeyEvent.VK_T); this.getContentPane().add(customChartPanel, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); this.getContentPane().add(UIPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), -107, 0)); this.getContentPane().add(jTabbedPane1, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); UIPanel.add(connectionPanel, null); UIPanel.add(selectFolderButton, null); UIPanel.add(logFileTextField, null); UIPanel.add(jLabel1logfilename, null); UIPanel.add(FQPathTextArea, null); ActionListener taskPerformer = new ActionListener() { public void actionPerformed(ActionEvent evt) { String theData = null; for (;;) { theData = LogChartFrame.this.logDataQueue.poll(); if (theData == null) break; try { dataLogTextArea.getDocument().insertString(dataLogTextArea.getDocument().getLength(), theData, null); } catch (BadLocationException e) { System.out.print( "BadLocationException in datalog textarea updater thread:" + e.toString() + "\n"); } } } }; this.updateLogTextAreaTimer = new Timer(1000, taskPerformer); this.updateLogTextAreaTimer.start(); }
From source file:pl.otros.logview.gui.LogViewMainFrame.java
private void initMenu() { JMenuBar menuBar = getJMenuBar(); if (menuBar == null) { menuBar = new JMenuBar(); setJMenuBar(menuBar);/* w w w . j ava 2s . c o m*/ } menuBar.removeAll(); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); JLabel labelOpenLog = new JLabel("Open log", Icons.FOLDER_OPEN, SwingConstants.LEFT); Font menuGroupFont = labelOpenLog.getFont().deriveFont(13f).deriveFont(Font.BOLD); labelOpenLog.setFont(menuGroupFont); fileMenu.add(labelOpenLog); JMenuItem openAutoDetectLog = new JMenuItem("Open log with autodetect type"); openAutoDetectLog.addActionListener(new ImportLogWithAutoDetectedImporterActionListener(otrosApplication)); openAutoDetectLog.setMnemonic(KeyEvent.VK_O); openAutoDetectLog.setIcon(Icons.WIZARD); fileMenu.add(openAutoDetectLog); JMenuItem tailAutoDetectLog = new JMenuItem("Tail log with autodetect type"); tailAutoDetectLog.addActionListener(new TailLogWithAutoDetectActionListener(otrosApplication)); tailAutoDetectLog.setMnemonic(KeyEvent.VK_T); tailAutoDetectLog.setIcon(Icons.ARROW_REPEAT); fileMenu.add(tailAutoDetectLog); fileMenu.add(new TailMultipleFilesIntoOneView(otrosApplication)); fileMenu.add(new ConnectToSocketHubAppenderAction(otrosApplication)); fileMenu.add(new JSeparator()); JLabel labelLogInvestigation = new JLabel("Log investigation", SwingConstants.LEFT); labelLogInvestigation.setFont(menuGroupFont); fileMenu.add(labelLogInvestigation); fileMenu.add(new OpenLogInvestigationAction(otrosApplication)); JMenuItem saveLogsInvest = new JMenuItem(new SaveLogInvestigationAction(otrosApplication)); enableDisableComponetsForTabs.addComponet(saveLogsInvest); fileMenu.add(saveLogsInvest); fileMenu.add(new JSeparator()); LogImporter[] importers = new LogImporter[0]; importers = logImportersContainer.getElements().toArray(importers); for (LogImporter logImporter : importers) { JMenuItem openLog = new JMenuItem("Open " + logImporter.getName() + " log"); openLog.addActionListener(new ImportLogWithGivenImporterActionListener(otrosApplication, logImporter)); if (logImporter.getKeyStrokeAccelelator() != null) { openLog.setAccelerator(KeyStroke.getKeyStroke(logImporter.getKeyStrokeAccelelator())); } if (logImporter.getMnemonic() > 0) { openLog.setMnemonic(logImporter.getMnemonic()); } Icon icon = logImporter.getIcon(); if (icon != null) { openLog.setIcon(icon); } fileMenu.add(openLog); } fileMenu.add(new JSeparator()); JLabel labelTailLog = new JLabel("Tail log [from begging of file]", Icons.ARROW_REPEAT, SwingConstants.LEFT); labelTailLog.setFont(menuGroupFont); fileMenu.add(labelTailLog); for (LogImporter logImporter : importers) { JMenuItem openLog = new JMenuItem("Tail " + logImporter.getName() + " log"); openLog.addActionListener(new TailLogActionListener(otrosApplication, logImporter)); if (logImporter.getKeyStrokeAccelelator() != null) { openLog.setAccelerator(KeyStroke.getKeyStroke(logImporter.getKeyStrokeAccelelator())); } if (logImporter.getMnemonic() > 0) { openLog.setMnemonic(logImporter.getMnemonic()); } Icon icon = logImporter.getIcon(); if (icon != null) { openLog.setIcon(icon); } fileMenu.add(openLog); } JMenuItem exitMenuItem = new JMenuItem("Exit", 'e'); exitMenuItem.setIcon(Icons.TURN_OFF); exitMenuItem.setAccelerator(KeyStroke.getKeyStroke("control F4")); exitAction = new ExitAction(this); exitMenuItem.addActionListener(exitAction); fileMenu.add(new JSeparator()); fileMenu.add(exitMenuItem); JMenu toolsMenu = new JMenu("Tools"); toolsMenu.setMnemonic(KeyEvent.VK_T); JMenuItem closeAll = new JMenuItem(new CloseAllTabsAction(otrosApplication)); enableDisableComponetsForTabs.addComponet(closeAll); ArrayList<SocketLogReader> logReaders = new ArrayList<SocketLogReader>(); toolsMenu.add(new JMenuItem(new StartSocketListener(otrosApplication, logReaders))); toolsMenu.add(new JMenuItem(new StopAllSocketListeners(otrosApplication, logReaders))); toolsMenu.add(new ShowMarkersEditor(otrosApplication)); toolsMenu.add(new ShowLog4jPatternParserEditor(otrosApplication)); toolsMenu.add(new ShowMessageColorizerEditor(otrosApplication)); toolsMenu.add(new ShowLoadedPlugins(otrosApplication)); toolsMenu.add(new ShowOlvLogs(otrosApplication)); toolsMenu.add(new OpenPreferencesAction(otrosApplication)); toolsMenu.add(closeAll); JMenu pluginsMenu = new JMenu("Plugins"); otrosApplication.setPluginsMenu(pluginsMenu); JMenu helpMenu = new JMenu("Help"); JMenuItem about = new JMenuItem("About"); AboutAction action = new AboutAction(otrosApplication); action.putValue(Action.NAME, "About"); about.setAction(action); helpMenu.add(about); helpMenu.add(new GoToDonatePageAction(otrosApplication)); JMenuItem checkForNewVersion = new JMenuItem(new CheckForNewVersionAction(otrosApplication)); helpMenu.add(checkForNewVersion); helpMenu.add(new GettingStartedAction(otrosApplication)); menuBar.add(fileMenu); menuBar.add(toolsMenu); menuBar.add(pluginsMenu); menuBar.add(helpMenu); }
From source file:edu.harvard.mcz.imagecapture.MainFrame.java
/** * This method initializes jMenuItem3 * //from w ww . j a v a2 s . co m * @return javax.swing.JMenuItem */ private JMenuItem getJMenuItemEditTemplates() { if (jMenuItemEditTemplates == null) { jMenuItemEditTemplates = new JMenuItem(); jMenuItemEditTemplates.setText("Edit Templates"); jMenuItemEditTemplates.setMnemonic(KeyEvent.VK_T); jMenuItemEditTemplates.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { PositionTemplateEditor templateEditor = new PositionTemplateEditor(); templateEditor.pack(); templateEditor.setVisible(true); } }); } return jMenuItemEditTemplates; }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.analise_geral.PanelAnaliseGeral.java
/** * Cria o menu editar do Frame Principal * /*from w ww .j a va2 s. co m*/ * @param menu */ private JMenu criaMenuEditar() { JMenu menu = new JMenu(GERAL.EDITAR); menu.setBackground(parentFrame.corDefault); menu.setMnemonic('E'); menu.setMnemonic(KeyEvent.VK_E); JMenuItem btnContraste = new JMenuItem(GERAL.ALTERAR_CONTRASTE); btnContraste.addActionListener(this); btnContraste.setActionCommand("Contraste"); // btnAumenta.setMnemonic('F'); // btnAumenta.setMnemonic(KeyEvent.VK_F); // btnAumenta.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD, // ActionEvent.CTRL_MASK)); btnContraste.setToolTipText(GERAL.DICA_CONTRASTE); btnContraste.getAccessibleContext().setAccessibleDescription(GERAL.DICA_CONTRASTE); menu.add(btnContraste); JMenuItem btnAumenta = new JMenuItem(GERAL.AUMENTA_FONTE); btnAumenta.addActionListener(this); btnAumenta.setActionCommand("AumentaFonte"); // btnAumenta.setMnemonic('F'); // btnAumenta.setMnemonic(KeyEvent.VK_F); btnAumenta.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD, ActionEvent.CTRL_MASK)); btnAumenta.setToolTipText(GERAL.DICA_AUMENTA_FONTE); btnAumenta.getAccessibleContext().setAccessibleDescription(GERAL.DICA_AUMENTA_FONTE); menu.add(btnAumenta); JMenuItem btnDiminui = new JMenuItem(GERAL.DIMINUI_FONTE); btnDiminui.addActionListener(this); btnDiminui.setActionCommand("DiminuiFonte"); // btnDiminui.setMnemonic('F'); // btnDiminui.setMnemonic(KeyEvent.VK_F); btnDiminui.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_SUBTRACT, ActionEvent.CTRL_MASK)); btnDiminui.setToolTipText(GERAL.DICA_DIMINUI_FONTE); btnDiminui.getAccessibleContext().setAccessibleDescription(GERAL.DICA_DIMINUI_FONTE); menu.add(btnDiminui); menu.add(new JSeparator()); JMenuItem btnProcurar = new JMenuItem(GERAL.PROCURAR); btnProcurar.addActionListener(this); btnProcurar.setActionCommand("Procurar"); btnProcurar.setMnemonic('P'); btnProcurar.setMnemonic(KeyEvent.VK_P); btnProcurar.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, ActionEvent.CTRL_MASK)); btnProcurar.setToolTipText(GERAL.DICA_PROCURAR); btnProcurar.getAccessibleContext().setAccessibleDescription(GERAL.DICA_PROCURAR); menu.add(btnProcurar); JMenuItem btnSelecionarTudo = new JMenuItem(GERAL.SELECIONAR_TUDO); btnSelecionarTudo.addActionListener(this); btnSelecionarTudo.setActionCommand("SelecionarTudo"); btnSelecionarTudo.setMnemonic('T'); btnSelecionarTudo.setMnemonic(KeyEvent.VK_T); btnSelecionarTudo.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, ActionEvent.CTRL_MASK)); btnSelecionarTudo.setToolTipText(GERAL.DICA_SELECIONAR_TUDO); btnSelecionarTudo.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SELECIONAR_TUDO); menu.add(btnSelecionarTudo); JMenuItem btnDesfazer = new JMenuItem(GERAL.DESFAZER); btnDesfazer.addActionListener(this); btnDesfazer.setActionCommand("Desfazer"); btnDesfazer.setMnemonic('z'); btnDesfazer.setMnemonic(KeyEvent.VK_Z); btnDesfazer.getAccessibleContext().setAccessibleDescription(GERAL.DICA_DESFAZER); btnDesfazer.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, ActionEvent.CTRL_MASK)); menu.add(btnDesfazer); menu.setEnabled(true); return menu; }
From source file:corelyzer.ui.CorelyzerApp.java
private void setupMenuStuff() { menuBar = new JMenuBar(); // Create File Menu JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); JMenuItem createSessionMenuItem = new JMenuItem("Create a Session", KeyEvent.VK_N); createSessionMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, MENU_MASK)); createSessionMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.createSession();/* w w w. j a v a 2 s .c o m*/ } }); createSessionMenuItem.setEnabled(true); fileMenu.add(createSessionMenuItem); createTrackMenuItem = new JMenuItem("Create a Track", KeyEvent.VK_T); createTrackMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, MENU_MASK)); createTrackMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.createTrack(); } }); createTrackMenuItem.setEnabled(false); fileMenu.add(createTrackMenuItem); fileMenu.addSeparator(); // Images JMenu loadImageMenu = new JMenu("Load Images"); loadImageMenuItem = new JMenuItem("Open Local Image Files...", KeyEvent.VK_M); loadImageMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, MENU_MASK)); loadImageMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.loadImageAction(); } }); loadImageMenu.add(loadImageMenuItem); // "Auto-load" 4/25/2012 brg JMenuItem autoLoadImageMenuItem = new JMenuItem("Open Image Listing..."); autoLoadImageMenuItem.setEnabled(true); autoLoadImageMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.loadImageListingAction(); } }); loadImageMenu.add(autoLoadImageMenuItem); // online image services JMenuItem chronosMenuItem = new JMenuItem("Online Image Services..."); loadImageMenu.add(chronosMenuItem); chronosMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { IODPListsDialog d = new IODPListsDialog(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisibleTab(1); d.setVisible(true); } }); fileMenu.add(loadImageMenu); // Numbercal data (plots) JMenu loadDataMenu = new JMenu("Load Data"); loadDataMenuItem = new JMenuItem("Open Local Dataset Files", KeyEvent.VK_D); loadDataMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, MENU_MASK)); loadDataMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { Runnable r = new Runnable() { public void run() { controller.loadData(); } }; new Thread(r).start(); } }); loadDataMenu.add(loadDataMenuItem); fileMenu.add(loadDataMenu); JMenuItem quickDataImportMenuItem = new JMenuItem("Quick Data Import..."); quickDataImportMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.quickDataImport(); } }); loadDataMenu.add(quickDataImportMenuItem); JMenuItem importDataMenuItem = new JMenuItem("Custom Data Import..."); importDataMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.importData(); } }); loadDataMenu.add(importDataMenuItem); // LoggingDB JMenuItem loggingDBMenuItem = new JMenuItem("LDEO logging DB..."); loggingDBMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { IODPListsDialog d = new IODPListsDialog(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisibleTab(2); d.setVisible(true); } }); loadDataMenu.add(loggingDBMenuItem); fileMenu.addSeparator(); loadStateFileMenuItem = new JMenuItem("Open a Session File", KeyEvent.VK_O); loadStateFileMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, MENU_MASK)); loadStateFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.loadStateFile(); } }); loadStateFileMenuItem.setEnabled(false); fileMenu.add(loadStateFileMenuItem); JMenuItem saveMenuItem = new JMenuItem("Save Session", KeyEvent.VK_S); saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MENU_MASK)); saveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { controller.saveCurrentSession(); } }); fileMenu.add(saveMenuItem); JMenuItem saveStateToFileMenuItem = new JMenuItem("Save Session As...", KeyEvent.VK_S); saveStateToFileMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, MENU_MASK)); saveStateToFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.saveStateToFile(); } }); fileMenu.add(saveStateToFileMenuItem); // Session History recentSessionsMenu = new JMenu("Recent Sessions"); controller.refreshSessionHistoryMenu(); fileMenu.add(recentSessionsMenu); fileMenu.addSeparator(); JMenu packageMenu = new JMenu("Core Archive"); JMenuItem importMenuItem = new JMenuItem("Import..."); importMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.importPackage(); } }); packageMenu.add(importMenuItem); JMenuItem exportMenuItem = new JMenuItem("Export..."); exportMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.exportTheWholeScene(); } }); packageMenu.add(exportMenuItem); fileMenu.add(packageMenu); JMenu limsMenu = new JMenu("IODP"); JMenuItem allIODPLists = new JMenuItem("All IODP lists..."); allIODPLists.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { IODPListsDialog d = new IODPListsDialog(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisible(true); } }); limsMenu.add(allIODPLists); JMenuItem loadLIMSTables = new JMenuItem("Load a section list..."); loadLIMSTables.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { IODPListsDialog d = new IODPListsDialog(getMainFrame()); d.loadLIMSTables(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisibleTab(0); d.setVisible(true); } }); limsMenu.add(loadLIMSTables); JMenuItem loadAffineTable = new JMenuItem("Load an affine table..."); loadAffineTable.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { IODPListsDialog d = new IODPListsDialog(getMainFrame()); d.loadAAffineTable(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisibleTab(3); d.setVisible(true); } }); limsMenu.add(loadAffineTable); JMenuItem loadSpliceTable = new JMenuItem("Load a splice table..."); loadSpliceTable.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { IODPListsDialog d = new IODPListsDialog(getMainFrame()); d.loadASpliceTable(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisibleTab(4); d.setVisible(true); } }); limsMenu.add(loadSpliceTable); fileMenu.add(limsMenu); JMenu disMenu = new JMenu("DIS"); JMenuItem disListMenuItem = new JMenuItem("Accessing DIS..."); disListMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { DISListsDialog d = new DISListsDialog(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisible(true); } }); JMenuItem disImport = new JMenuItem("Import..."); disImport.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.disImport(); } }); JMenuItem disExport = new JMenuItem("Export..."); disExport.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.disExport(); } }); JMenuItem disBatchDataLoad = new JMenuItem("Load Tab Delimited Data File..."); disBatchDataLoad.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.disBatchDataLoad(); } }); disMenu.add(disListMenuItem); disMenu.add(disImport); disMenu.add(disExport); disMenu.add(disBatchDataLoad); fileMenu.add(disMenu); JMenuItem saveOutputToFileMenuItem = new JMenuItem("Export Sheets...", KeyEvent.VK_A); saveOutputToFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.saveOutputToFile(); } }); fileMenu.add(saveOutputToFileMenuItem); fileMenu.addSeparator(); JMenuItem quitMenuItem = new JMenuItem("Quit"); fileMenu.add(quitMenuItem); quitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, MENU_MASK)); quitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.quit(); } }); menuBar.add(fileMenu); // Create Edit Menu JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(KeyEvent.VK_E); JMenuItem clearImageCacheMenuItem = new JMenuItem("Clear Image Cache...", KeyEvent.VK_I); clearImageCacheMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.clearImageCache(); } }); editMenu.add(clearImageCacheMenuItem); editMenu.addSeparator(); JMenuItem depthDirection = new JMenuItem("Switch Depth Direction", KeyEvent.VK_K); depthDirection.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K, MENU_MASK)); depthDirection.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { boolean b = SceneGraph.getDepthOrientation(); SceneGraph.setDepthOrientation(!b); CorelyzerApp.getApp().updateGLWindows(); } }); editMenu.add(depthDirection); JMenuItem tour = new JMenuItem("Tour..."); tour.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { CRNavigationSetupDialog dlg = new CRNavigationSetupDialog(); dlg.pack(); dlg.setLocationRelativeTo(getApp().getMainFrame()); dlg.setAlwaysOnTop(true); dlg.setVisible(true); } }); editMenu.add(tour); editMenu.addSeparator(); JMenuItem preferencesMenuItem = new JMenuItem("Preferences..."); editMenu.add(preferencesMenuItem); preferencesMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.doPreferences(); } }); menuBar.add(editMenu); // Create Share Menu JMenu shareMenu = new JMenu("Share"); JMenuItem publishMenuItem = new JMenuItem("Publish..."); publishMenuItem.setEnabled(true); publishMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { controller.publishASession(); } }); shareMenu.add(publishMenuItem); JMenuItem listMenuItem = new JMenuItem("List..."); listMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { controller.listSessions(); } }); shareMenu.add(listMenuItem); shareMenu.addSeparator(); friendsMenu = new JMenu("Friends"); shareMenu.add(friendsMenu); menuBar.add(shareMenu); // Create Debug Menu JMenu debugMenu = new JMenu("Debug"); debugMenu.setMnemonic(KeyEvent.VK_D); JMenuItem matchTestMenuItem = new JMenuItem("Match-Test", KeyEvent.VK_B); matchTestMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.testAndMatch(); } }); debugMenu.add(matchTestMenuItem); if ((System.getenv("DEBUG") != null) && System.getenv("DEBUG").equals("YES")) { menuBar.add(shareMenu); } // Create the Plugin Menu pluginMenu = new JMenu("Plugins"); menuBar.add(pluginMenu); pluginMenuItemVec = new Vector<JMenuItem>(); // Lists JMenu listsMenu = new JMenu("Lists"); JMenuItem iodpLists = new JMenuItem("IODP lists..."); iodpLists.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { IODPListsDialog d = new IODPListsDialog(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisible(true); } }); listsMenu.add(iodpLists); JMenuItem disLists = new JMenuItem("DIS lists..."); disLists.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { DISListsDialog d = new DISListsDialog(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisible(true); } }); listsMenu.add(disLists); JMenu annotLists = new JMenu("Annotation"); JMenuItem freeformsItem = new JMenuItem("Default"); freeformsItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { FreeformAnnotationListDialog dlg = new FreeformAnnotationListDialog(getApp().getMainFrame()); dlg.pack(); dlg.setLocationRelativeTo(getApp().getMainFrame()); dlg.onRefresh(); dlg.setAlwaysOnTop(true); dlg.setVisible(true); } }); annotLists.add(freeformsItem); JMenuItem clastListItem = new JMenuItem("Clast"); clastListItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { ClastStatisticsDialog dlg = new ClastStatisticsDialog(getApp().getMainFrame()); dlg.pack(); dlg.setLocationRelativeTo(getApp().getMainFrame()); dlg.onRefresh(); dlg.setAlwaysOnTop(true); dlg.setVisible(true); } }); annotLists.add(clastListItem); JMenuItem sampleReqsItem = new JMenuItem("Sample"); sampleReqsItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { SampleRequestListDialog dlg = new SampleRequestListDialog(getApp().getMainFrame()); dlg.pack(); dlg.setLocationRelativeTo(getApp().getMainFrame()); dlg.onRefresh(); dlg.setAlwaysOnTop(true); dlg.setVisible(true); } }); annotLists.add(sampleReqsItem); listsMenu.add(annotLists); menuBar.add(listsMenu); // Create Tools Menu JMenu toolsMenu = new JMenu("Tools"); JMenuItem wholeCoreViewerMenuItem = new JMenuItem("Get 3D Whole Core Imagery Viewer..."); wholeCoreViewerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { try { String app; String url = "http://www.evl.uic.edu/cavern/corewall/SciVizCore/"; if (System.getProperty("os.name").toLowerCase().contains("windows")) { app = "cmd.exe /c explorer " + url; Runtime.getRuntime().exec(app); } else { app = "open"; String[] cmd = { app, url }; Runtime.getRuntime().exec(cmd); } } catch (IOException ex) { System.err.println("IOException in opening SciVizCore link"); } } }); toolsMenu.add(wholeCoreViewerMenuItem); // DEBUG String debug = System.getProperty("DEBUG"); if ((debug != null) && System.getProperty("DEBUG").equals("true")) { JMenuItem gcItem = new JMenuItem("GC"); gcItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { long mem0 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); System.out.println("- B4 mem:\t" + mem0 / 1000000.0f); int trials = 10000; for (int i = 0; i < trials; i++) { updateGLWindows(); } long mem1 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); System.out.println("- " + trials + " mem:\t" + mem1 / 1000000.0f); System.gc(); System.gc(); System.gc(); long mem2 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); System.out.println("- AferGC mem:\t" + mem2 / 1000000.0f); } }); toolsMenu.add(gcItem); } menuBar.add(toolsMenu); // Create Help Menu // Create JavaHelp hooks File helpSet = new File("help/jhelpset.hs"); HelpSet hs = null; try { URL hsURL = helpSet.toURI().toURL(); hs = new HelpSet(null, hsURL); } catch (HelpSetException e) { JOptionPane.showMessageDialog(getMainFrame(), "Cannot find help: format error."); e.printStackTrace(); } catch (MalformedURLException e) { JOptionPane.showMessageDialog(getMainFrame(), "Cannot find help: malformed URL."); e.printStackTrace(); } // Help UI JMenu helpMenu = new JMenu("Help"); JMenuItem helpMenuItem = new JMenuItem("Help", KeyEvent.VK_H); if (hs != null) { HelpBroker hb = hs.createHelpBroker(); helpActionListener = new CSH.DisplayHelpFromSource(hb); helpMenuItem.addActionListener(helpActionListener); } else { helpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.helpAction(); } }); } helpMenu.add(helpMenuItem); helpMenu.addSeparator(); JMenuItem aboutMenuItem = new JMenuItem("About Corelyzer"); helpMenu.add(aboutMenuItem); aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.about(); } }); menuBar.add(helpMenu); mainFrame.setJMenuBar(menuBar); }
From source file:org.sikuli.ide.SikuliIDE.java
private void initViewMenu() throws NoSuchMethodException { int scMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); _viewMenu.setMnemonic(java.awt.event.KeyEvent.VK_V); if (prefs.getPrefMoreCommandBar()) { chkShowCmdList = new JCheckBoxMenuItem(_I("menuViewCommandList"), true); _viewMenu.add(/*from w w w.j ava2s . c o m*/ createMenuItem(chkShowCmdList, KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, scMask), new ViewAction(ViewAction.CMD_LIST))); } chkShowThumbs = new JCheckBoxMenuItem(_I("menuViewShowThumbs"), false); _viewMenu.add(createMenuItem(chkShowThumbs, KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, scMask), new ViewAction(ViewAction.SHOW_THUMBS))); //TODO Message Area clear //TODO Message Area LineBreak }
From source file:com.nikonhacker.gui.EmulatorUI.java
@SuppressWarnings("MagicConstant") protected JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenuItem tmpMenuItem;// w ww. j a v a 2 s . com //Set up the file menu. JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu); //load image for (int chip = 0; chip < 2; chip++) { loadMenuItem[chip] = new JMenuItem("Load " + Constants.CHIP_LABEL[chip] + " firmware image"); if (chip == Constants.CHIP_FR) loadMenuItem[chip].setMnemonic(KEY_EVENT_LOAD); loadMenuItem[chip].setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_LOAD, KEY_CHIP_MODIFIER[chip])); loadMenuItem[chip].setActionCommand(COMMAND_IMAGE_LOAD[chip]); loadMenuItem[chip].addActionListener(this); fileMenu.add(loadMenuItem[chip]); } fileMenu.add(new JSeparator()); //decoder tmpMenuItem = new JMenuItem("Decode firmware"); tmpMenuItem.setMnemonic(KeyEvent.VK_D); tmpMenuItem.setActionCommand(COMMAND_DECODE); tmpMenuItem.addActionListener(this); fileMenu.add(tmpMenuItem); //encoder tmpMenuItem = new JMenuItem("Encode firmware (alpha)"); tmpMenuItem.setMnemonic(KeyEvent.VK_E); tmpMenuItem.setActionCommand(COMMAND_ENCODE); tmpMenuItem.addActionListener(this); // fileMenu.add(tmpMenuItem); fileMenu.add(new JSeparator()); //decoder tmpMenuItem = new JMenuItem("Decode lens correction data"); //tmpMenuItem.setMnemonic(KeyEvent.VK_D); tmpMenuItem.setActionCommand(COMMAND_DECODE_NKLD); tmpMenuItem.addActionListener(this); fileMenu.add(tmpMenuItem); fileMenu.add(new JSeparator()); //Save state tmpMenuItem = new JMenuItem("Save state"); tmpMenuItem.setActionCommand(COMMAND_SAVE_STATE); tmpMenuItem.addActionListener(this); fileMenu.add(tmpMenuItem); //Load state tmpMenuItem = new JMenuItem("Load state"); tmpMenuItem.setActionCommand(COMMAND_LOAD_STATE); tmpMenuItem.addActionListener(this); fileMenu.add(tmpMenuItem); fileMenu.add(new JSeparator()); //quit tmpMenuItem = new JMenuItem("Quit"); tmpMenuItem.setMnemonic(KEY_EVENT_QUIT); tmpMenuItem.setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_QUIT, ActionEvent.ALT_MASK)); tmpMenuItem.setActionCommand(COMMAND_QUIT); tmpMenuItem.addActionListener(this); fileMenu.add(tmpMenuItem); //Set up the run menu. JMenu runMenu = new JMenu("Run"); runMenu.setMnemonic(KeyEvent.VK_R); menuBar.add(runMenu); for (int chip = 0; chip < 2; chip++) { //emulator play playMenuItem[chip] = new JMenuItem("Start (or resume) " + Constants.CHIP_LABEL[chip] + " emulator"); playMenuItem[chip].setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_RUN[chip], ActionEvent.ALT_MASK)); playMenuItem[chip].setActionCommand(COMMAND_EMULATOR_PLAY[chip]); playMenuItem[chip].addActionListener(this); runMenu.add(playMenuItem[chip]); //emulator debug debugMenuItem[chip] = new JMenuItem("Debug " + Constants.CHIP_LABEL[chip] + " emulator"); debugMenuItem[chip].setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_DEBUG[chip], ActionEvent.ALT_MASK)); debugMenuItem[chip].setActionCommand(COMMAND_EMULATOR_DEBUG[chip]); debugMenuItem[chip].addActionListener(this); runMenu.add(debugMenuItem[chip]); //emulator pause pauseMenuItem[chip] = new JMenuItem("Pause " + Constants.CHIP_LABEL[chip] + " emulator"); pauseMenuItem[chip].setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_PAUSE[chip], ActionEvent.ALT_MASK)); pauseMenuItem[chip].setActionCommand(COMMAND_EMULATOR_PAUSE[chip]); pauseMenuItem[chip].addActionListener(this); runMenu.add(pauseMenuItem[chip]); //emulator step stepMenuItem[chip] = new JMenuItem("Step " + Constants.CHIP_LABEL[chip] + " emulator"); stepMenuItem[chip].setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_STEP[chip], ActionEvent.ALT_MASK)); stepMenuItem[chip].setActionCommand(COMMAND_EMULATOR_STEP[chip]); stepMenuItem[chip].addActionListener(this); runMenu.add(stepMenuItem[chip]); //emulator stop stopMenuItem[chip] = new JMenuItem("Stop and reset " + Constants.CHIP_LABEL[chip] + " emulator"); stopMenuItem[chip].setActionCommand(COMMAND_EMULATOR_STOP[chip]); stopMenuItem[chip].addActionListener(this); runMenu.add(stopMenuItem[chip]); runMenu.add(new JSeparator()); //setup breakpoints breakpointMenuItem[chip] = new JMenuItem("Setup " + Constants.CHIP_LABEL[chip] + " breakpoints"); breakpointMenuItem[chip].setActionCommand(COMMAND_SETUP_BREAKPOINTS[chip]); breakpointMenuItem[chip].addActionListener(this); runMenu.add(breakpointMenuItem[chip]); if (chip == Constants.CHIP_FR) { runMenu.add(new JSeparator()); } } //Set up the components menu. JMenu componentsMenu = new JMenu("Components"); componentsMenu.setMnemonic(KeyEvent.VK_O); menuBar.add(componentsMenu); for (int chip = 0; chip < 2; chip++) { //CPU state cpuStateMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " CPU State window"); if (chip == Constants.CHIP_FR) cpuStateMenuItem[chip].setMnemonic(KEY_EVENT_CPUSTATE); cpuStateMenuItem[chip] .setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_CPUSTATE, KEY_CHIP_MODIFIER[chip])); cpuStateMenuItem[chip].setActionCommand(COMMAND_TOGGLE_CPUSTATE_WINDOW[chip]); cpuStateMenuItem[chip].addActionListener(this); componentsMenu.add(cpuStateMenuItem[chip]); //memory hex editor memoryHexEditorMenuItem[chip] = new JCheckBoxMenuItem( Constants.CHIP_LABEL[chip] + " Memory hex editor"); if (chip == Constants.CHIP_FR) memoryHexEditorMenuItem[chip].setMnemonic(KEY_EVENT_MEMORY); memoryHexEditorMenuItem[chip] .setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_MEMORY, KEY_CHIP_MODIFIER[chip])); memoryHexEditorMenuItem[chip].setActionCommand(COMMAND_TOGGLE_MEMORY_HEX_EDITOR[chip]); memoryHexEditorMenuItem[chip].addActionListener(this); componentsMenu.add(memoryHexEditorMenuItem[chip]); //Interrupt controller interruptControllerMenuItem[chip] = new JCheckBoxMenuItem( Constants.CHIP_LABEL[chip] + " interrupt controller"); interruptControllerMenuItem[chip].setActionCommand(COMMAND_TOGGLE_INTERRUPT_CONTROLLER_WINDOW[chip]); interruptControllerMenuItem[chip].addActionListener(this); componentsMenu.add(interruptControllerMenuItem[chip]); //Programmble timers programmableTimersMenuItem[chip] = new JCheckBoxMenuItem( Constants.CHIP_LABEL[chip] + " programmable timers"); programmableTimersMenuItem[chip].setActionCommand(COMMAND_TOGGLE_PROGRAMMABLE_TIMERS_WINDOW[chip]); programmableTimersMenuItem[chip].addActionListener(this); componentsMenu.add(programmableTimersMenuItem[chip]); //Serial interface serialInterfacesMenuItem[chip] = new JCheckBoxMenuItem( Constants.CHIP_LABEL[chip] + " serial interfaces"); serialInterfacesMenuItem[chip].setActionCommand(COMMAND_TOGGLE_SERIAL_INTERFACES[chip]); serialInterfacesMenuItem[chip].addActionListener(this); componentsMenu.add(serialInterfacesMenuItem[chip]); // I/O ioPortsMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " I/O ports"); ioPortsMenuItem[chip].setActionCommand(COMMAND_TOGGLE_IO_PORTS_WINDOW[chip]); ioPortsMenuItem[chip].addActionListener(this); componentsMenu.add(ioPortsMenuItem[chip]); //Serial devices serialDevicesMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " serial devices"); serialDevicesMenuItem[chip].setActionCommand(COMMAND_TOGGLE_SERIAL_DEVICES[chip]); serialDevicesMenuItem[chip].addActionListener(this); componentsMenu.add(serialDevicesMenuItem[chip]); componentsMenu.add(new JSeparator()); } //screen emulator: FR80 only screenEmulatorMenuItem = new JCheckBoxMenuItem("Screen emulator (FR only)"); screenEmulatorMenuItem.setMnemonic(KEY_EVENT_SCREEN); screenEmulatorMenuItem.setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_SCREEN, ActionEvent.ALT_MASK)); screenEmulatorMenuItem.setActionCommand(COMMAND_TOGGLE_SCREEN_EMULATOR); screenEmulatorMenuItem.addActionListener(this); componentsMenu.add(screenEmulatorMenuItem); //Component 4006: FR80 only component4006MenuItem = new JCheckBoxMenuItem("Component 4006 window (FR only)"); component4006MenuItem.setMnemonic(KeyEvent.VK_4); component4006MenuItem.setActionCommand(COMMAND_TOGGLE_COMPONENT_4006_WINDOW); component4006MenuItem.addActionListener(this); componentsMenu.add(component4006MenuItem); componentsMenu.add(new JSeparator()); //A/D converter: TX19 only for now adConverterMenuItem[Constants.CHIP_TX] = new JCheckBoxMenuItem( Constants.CHIP_LABEL[Constants.CHIP_TX] + " A/D converter (TX only)"); adConverterMenuItem[Constants.CHIP_TX].setActionCommand(COMMAND_TOGGLE_AD_CONVERTER[Constants.CHIP_TX]); adConverterMenuItem[Constants.CHIP_TX].addActionListener(this); componentsMenu.add(adConverterMenuItem[Constants.CHIP_TX]); //Front panel: TX19 only frontPanelMenuItem = new JCheckBoxMenuItem("Front panel (TX only)"); frontPanelMenuItem.setActionCommand(COMMAND_TOGGLE_FRONT_PANEL); frontPanelMenuItem.addActionListener(this); componentsMenu.add(frontPanelMenuItem); //Set up the trace menu. JMenu traceMenu = new JMenu("Trace"); traceMenu.setMnemonic(KeyEvent.VK_C); menuBar.add(traceMenu); for (int chip = 0; chip < 2; chip++) { //memory activity viewer memoryActivityViewerMenuItem[chip] = new JCheckBoxMenuItem( Constants.CHIP_LABEL[chip] + " Memory activity viewer"); memoryActivityViewerMenuItem[chip].setActionCommand(COMMAND_TOGGLE_MEMORY_ACTIVITY_VIEWER[chip]); memoryActivityViewerMenuItem[chip].addActionListener(this); traceMenu.add(memoryActivityViewerMenuItem[chip]); //disassembly disassemblyMenuItem[chip] = new JCheckBoxMenuItem( "Real-time " + Constants.CHIP_LABEL[chip] + " disassembly log"); if (chip == Constants.CHIP_FR) disassemblyMenuItem[chip].setMnemonic(KEY_EVENT_REALTIME_DISASSEMBLY); disassemblyMenuItem[chip].setAccelerator( KeyStroke.getKeyStroke(KEY_EVENT_REALTIME_DISASSEMBLY, KEY_CHIP_MODIFIER[chip])); disassemblyMenuItem[chip].setActionCommand(COMMAND_TOGGLE_DISASSEMBLY_WINDOW[chip]); disassemblyMenuItem[chip].addActionListener(this); traceMenu.add(disassemblyMenuItem[chip]); //Custom logger customMemoryRangeLoggerMenuItem[chip] = new JCheckBoxMenuItem( "Custom " + Constants.CHIP_LABEL[chip] + " logger window"); customMemoryRangeLoggerMenuItem[chip].setActionCommand(COMMAND_TOGGLE_CUSTOM_LOGGER_WINDOW[chip]); customMemoryRangeLoggerMenuItem[chip].addActionListener(this); traceMenu.add(customMemoryRangeLoggerMenuItem[chip]); //Call Stack logger callStackMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " Call stack logger"); callStackMenuItem[chip].setActionCommand(COMMAND_TOGGLE_CALL_STACK_WINDOW[chip]); callStackMenuItem[chip].addActionListener(this); traceMenu.add(callStackMenuItem[chip]); //ITRON Object iTronObjectMenuItem[chip] = new JCheckBoxMenuItem("ITRON " + Constants.CHIP_LABEL[chip] + " Objects"); iTronObjectMenuItem[chip].setActionCommand(COMMAND_TOGGLE_ITRON_OBJECT_WINDOW[chip]); iTronObjectMenuItem[chip].addActionListener(this); traceMenu.add(iTronObjectMenuItem[chip]); //ITRON Return Stack iTronReturnStackMenuItem[chip] = new JCheckBoxMenuItem( "ITRON " + Constants.CHIP_LABEL[chip] + " Return stack"); iTronReturnStackMenuItem[chip].setActionCommand(COMMAND_TOGGLE_ITRON_RETURN_STACK_WINDOW[chip]); iTronReturnStackMenuItem[chip].addActionListener(this); traceMenu.add(iTronReturnStackMenuItem[chip]); traceMenu.add(new JSeparator()); } //Set up the source menu. JMenu sourceMenu = new JMenu("Source"); sourceMenu.setMnemonic(KEY_EVENT_SCREEN); menuBar.add(sourceMenu); // FR syscall symbols generateSysSymbolsMenuItem = new JMenuItem( "Generate " + Constants.CHIP_LABEL[Constants.CHIP_FR] + " system call symbols"); generateSysSymbolsMenuItem.setActionCommand(COMMAND_GENERATE_SYS_SYMBOLS); generateSysSymbolsMenuItem.addActionListener(this); sourceMenu.add(generateSysSymbolsMenuItem); for (int chip = 0; chip < 2; chip++) { sourceMenu.add(new JSeparator()); //analyse / disassemble analyseMenuItem[chip] = new JMenuItem("Analyse / Disassemble " + Constants.CHIP_LABEL[chip] + " code"); analyseMenuItem[chip].setActionCommand(COMMAND_ANALYSE_DISASSEMBLE[chip]); analyseMenuItem[chip].addActionListener(this); sourceMenu.add(analyseMenuItem[chip]); sourceMenu.add(new JSeparator()); //code structure codeStructureMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " code structure"); codeStructureMenuItem[chip].setActionCommand(COMMAND_TOGGLE_CODE_STRUCTURE_WINDOW[chip]); codeStructureMenuItem[chip].addActionListener(this); sourceMenu.add(codeStructureMenuItem[chip]); //source code sourceCodeMenuItem[chip] = new JCheckBoxMenuItem(Constants.CHIP_LABEL[chip] + " source code"); if (chip == Constants.CHIP_FR) sourceCodeMenuItem[chip].setMnemonic(KEY_EVENT_SOURCE); sourceCodeMenuItem[chip] .setAccelerator(KeyStroke.getKeyStroke(KEY_EVENT_SOURCE, KEY_CHIP_MODIFIER[chip])); sourceCodeMenuItem[chip].setActionCommand(COMMAND_TOGGLE_SOURCE_CODE_WINDOW[chip]); sourceCodeMenuItem[chip].addActionListener(this); sourceMenu.add(sourceCodeMenuItem[chip]); if (chip == Constants.CHIP_FR) { sourceMenu.add(new JSeparator()); } } //Set up the tools menu. JMenu toolsMenu = new JMenu("Tools"); toolsMenu.setMnemonic(KeyEvent.VK_T); menuBar.add(toolsMenu); for (int chip = 0; chip < 2; chip++) { // save/load memory area saveLoadMemoryMenuItem[chip] = new JMenuItem( "Save/Load " + Constants.CHIP_LABEL[chip] + " memory area"); saveLoadMemoryMenuItem[chip].setActionCommand(COMMAND_SAVE_LOAD_MEMORY[chip]); saveLoadMemoryMenuItem[chip].addActionListener(this); toolsMenu.add(saveLoadMemoryMenuItem[chip]); //chip options chipOptionsMenuItem[chip] = new JMenuItem(Constants.CHIP_LABEL[chip] + " options"); chipOptionsMenuItem[chip].setActionCommand(COMMAND_CHIP_OPTIONS[chip]); chipOptionsMenuItem[chip].addActionListener(this); toolsMenu.add(chipOptionsMenuItem[chip]); toolsMenu.add(new JSeparator()); } //disassembly options uiOptionsMenuItem = new JMenuItem("Preferences"); uiOptionsMenuItem.setActionCommand(COMMAND_UI_OPTIONS); uiOptionsMenuItem.addActionListener(this); toolsMenu.add(uiOptionsMenuItem); //Set up the help menu. JMenu helpMenu = new JMenu("?"); menuBar.add(helpMenu); //about JMenuItem aboutMenuItem = new JMenuItem("About"); aboutMenuItem.setActionCommand(COMMAND_ABOUT); aboutMenuItem.addActionListener(this); helpMenu.add(aboutMenuItem); // JMenuItem testMenuItem = new JMenuItem("Test"); // testMenuItem.setActionCommand(COMMAND_TEST); // testMenuItem.addActionListener(this); // helpMenu.add(testMenuItem); // Global "Keep in sync" setting menuBar.add(Box.createHorizontalGlue()); final JCheckBox syncEmulators = new JCheckBox("Keep emulators in sync"); syncEmulators.setSelected(prefs.isSyncPlay()); framework.getMasterClock().setSyncPlay(prefs.isSyncPlay()); syncEmulators.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { prefs.setSyncPlay(syncEmulators.isSelected()); framework.getMasterClock().setSyncPlay(syncEmulators.isSelected()); } }); menuBar.add(syncEmulators); return menuBar; }