List of usage examples for java.awt.event KeyEvent VK_E
int VK_E
To view the source code for java.awt.event KeyEvent VK_E.
Click Source Link
From source file:ButtonHtmlDemo.java
public ButtonHtmlDemo() { ImageIcon leftButtonIcon = createImageIcon("images/right.gif"); ImageIcon middleButtonIcon = createImageIcon("images/middle.gif"); ImageIcon rightButtonIcon = createImageIcon("images/left.gif"); b1 = new JButton("<html><center><b><u>D</u>isable</b><br>" + "<font color=#ffffdd>middle button</font>", leftButtonIcon);// w ww . j a v a2 s. c om Font font = b1.getFont().deriveFont(Font.PLAIN); b1.setFont(font); b1.setVerticalTextPosition(AbstractButton.CENTER); b1.setHorizontalTextPosition(AbstractButton.LEADING); //aka LEFT, for // left-to-right // locales b1.setMnemonic(KeyEvent.VK_D); b1.setActionCommand("disable"); b2 = new JButton("middle button", middleButtonIcon); b2.setFont(font); b2.setForeground(new Color(0xffffdd)); b2.setVerticalTextPosition(AbstractButton.BOTTOM); b2.setHorizontalTextPosition(AbstractButton.CENTER); b2.setMnemonic(KeyEvent.VK_M); b3 = new JButton("<html><center><b><u>E</u>nable</b><br>" + "<font color=#ffffdd>middle button</font>", rightButtonIcon); b3.setFont(font); //Use the default text position of CENTER, TRAILING (RIGHT). b3.setMnemonic(KeyEvent.VK_E); b3.setActionCommand("enable"); b3.setEnabled(false); //Listen for actions on buttons 1 and 3. b1.addActionListener(this); b3.addActionListener(this); b1.setToolTipText("Click this button to disable the middle button."); b2.setToolTipText("This middle button does nothing when you click it."); b3.setToolTipText("Click this button to enable the middle button."); //Add Components to this container, using the default FlowLayout. add(b1); add(b2); add(b3); }
From source file:TextCutPaste.java
/** * Create an Edit menu to support cut/copy/paste. *///from w ww. ja va 2 s . c om public JMenuBar createMenuBar() { JMenuItem menuItem = null; JMenuBar menuBar = new JMenuBar(); JMenu mainMenu = new JMenu("Edit"); mainMenu.setMnemonic(KeyEvent.VK_E); menuItem = new JMenuItem(new DefaultEditorKit.CutAction()); menuItem.setText("Cut"); menuItem.setMnemonic(KeyEvent.VK_T); mainMenu.add(menuItem); menuItem = new JMenuItem(new DefaultEditorKit.CopyAction()); menuItem.setText("Copy"); menuItem.setMnemonic(KeyEvent.VK_C); mainMenu.add(menuItem); menuItem = new JMenuItem(new DefaultEditorKit.PasteAction()); menuItem.setText("Paste"); menuItem.setMnemonic(KeyEvent.VK_P); mainMenu.add(menuItem); menuBar.add(mainMenu); return menuBar; }
From source file:be.fedict.eid.tsl.tool.TslTool.java
private void initFileMenu(JMenuBar menuBar) { JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu);// ww w . jav a 2 s . c om initNewMenu(fileMenu); addActionMenuItem("Open", KeyEvent.VK_O, OPEN_ACTION_COMMAND, fileMenu); fileMenu.addSeparator(); this.signMenuItem = addActionMenuItem("Sign", KeyEvent.VK_S, SIGN_ACTION_COMMAND, fileMenu, false); this.saveMenuItem = addActionMenuItem("Save", KeyEvent.VK_A, SAVE_ACTION_COMMAND, fileMenu, false); this.saveAsMenuItem = addActionMenuItem("Save As", KeyEvent.VK_V, SAVE_AS_ACTION_COMMAND, fileMenu, false); this.exportMenuItem = addActionMenuItem("Export", KeyEvent.VK_E, EXPORT_ACTION_COMMAND, fileMenu, false); this.closeMenuItem = addActionMenuItem("Close", KeyEvent.VK_C, CLOSE_ACTION_COMMAND, fileMenu, false); fileMenu.addSeparator(); addActionMenuItem("Exit", KeyEvent.VK_X, EXIT_ACTION_COMMAND, fileMenu); }
From source file:DragColorTextFieldDemo.java
public JMenuBar createMenuBar() { JMenuItem menuItem = null;//from w w w . j ava 2 s . c o m JMenuBar menuBar = new JMenuBar(); JMenu mainMenu = new JMenu("Edit"); mainMenu.setMnemonic(KeyEvent.VK_E); menuItem = new JMenuItem(new DefaultEditorKit.CutAction()); menuItem.setText("Cut"); menuItem.setMnemonic(KeyEvent.VK_T); mainMenu.add(menuItem); menuItem = new JMenuItem(new DefaultEditorKit.CopyAction()); menuItem.setText("Copy"); menuItem.setMnemonic(KeyEvent.VK_C); mainMenu.add(menuItem); menuItem = new JMenuItem(new DefaultEditorKit.PasteAction()); menuItem.setText("Paste"); menuItem.setMnemonic(KeyEvent.VK_P); mainMenu.add(menuItem); menuBar.add(mainMenu); return menuBar; }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.AnnotationReportApplet.java
private void createActions() { //file//from w w w . j a v a 2s .c o m theActionManager.add("print", FileUtils.defaultThemeManager.getImageIcon("print"), "Print...", KeyEvent.VK_P, "ctrl P", this); //edit theActionManager.add("undo", FileUtils.defaultThemeManager.getImageIcon("undo"), "Undo", KeyEvent.VK_U, "ctrl Z", this); theActionManager.add("redo", FileUtils.defaultThemeManager.getImageIcon("redo"), "Redo", KeyEvent.VK_R, "ctrl Y", this); theActionManager.add("cut", FileUtils.defaultThemeManager.getImageIcon("cut"), "Cut", KeyEvent.VK_T, "ctrl X", this); theActionManager.add("copy", FileUtils.defaultThemeManager.getImageIcon("copy"), "Copy", KeyEvent.VK_C, "ctrl C", this); theActionManager.add("delete", FileUtils.defaultThemeManager.getImageIcon("delete"), "Delete", KeyEvent.VK_DELETE, "", this); theActionManager.add("screenshot", FileUtils.defaultThemeManager.getImageIcon("screenshot"), "Screenshot", KeyEvent.VK_PRINTSCREEN, "PRINTSCREEN", this); theActionManager.add("selectall", FileUtils.defaultThemeManager.getImageIcon("selectall"), "Select all", KeyEvent.VK_A, "ctrl A", this); theActionManager.add("selectnone", FileUtils.defaultThemeManager.getImageIcon("selectnone"), "Select none", KeyEvent.VK_E, "ESCAPE", this); theActionManager.add("enlarge", FileUtils.defaultThemeManager.getImageIcon("enlarge"), "Enlarge selected structures", -1, "", this); theActionManager.add("resetsize", FileUtils.defaultThemeManager.getImageIcon("resetsize"), "Reset size of selected structures to default value", -1, "", this); theActionManager.add("shrink", FileUtils.defaultThemeManager.getImageIcon("shrink"), "Shrink selected structures", -1, "", this); theActionManager.add("ungroup", FileUtils.defaultThemeManager.getImageIcon("ungroup"), "Ungroup selected structures", -1, "", this); theActionManager.add("group", FileUtils.defaultThemeManager.getImageIcon("group"), "Group selected structures", -1, "", this); theActionManager.add("placestructures", FileUtils.defaultThemeManager.getImageIcon("placestructures"), "Automatic place all structures", -1, "", this); // view theActionManager.add("zoomnone", FileUtils.defaultThemeManager.getImageIcon("zoomnone"), "Reset zoom", -1, "", this); theActionManager.add("zoomin", FileUtils.defaultThemeManager.getImageIcon("zoomin"), "Zoom in", -1, "", this); theActionManager.add("zoomout", FileUtils.defaultThemeManager.getImageIcon("zoomout"), "Zoom out", -1, "", this); theActionManager.add("notation=" + GraphicOptions.NOTATION_CFG, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "CFG notation", KeyEvent.VK_C, "", this); theActionManager.add("notation=" + GraphicOptions.NOTATION_CFGBW, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "CFG black and white notation", KeyEvent.VK_B, "", this); theActionManager.add("notation=" + GraphicOptions.NOTATION_CFGLINK, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "CFG with linkage placement notation", KeyEvent.VK_L, "", this); theActionManager.add("notation=" + GraphicOptions.NOTATION_UOXF, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "UOXF notation", KeyEvent.VK_O, "", this); theActionManager.add("notation=" + GraphicOptions.NOTATION_TEXT, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "Text only notation", KeyEvent.VK_T, "", this); theActionManager.add("display=" + GraphicOptions.DISPLAY_COMPACT, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "compact view", KeyEvent.VK_O, "", this); theActionManager.add("display=" + GraphicOptions.DISPLAY_NORMAL, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "normal view", KeyEvent.VK_N, "", this); theActionManager.add("display=" + GraphicOptions.DISPLAY_NORMALINFO, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "normal view with linkage info", KeyEvent.VK_I, "", this); theActionManager.add("display=" + GraphicOptions.DISPLAY_CUSTOM, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "custom view with user settings", KeyEvent.VK_K, "", this); theActionManager.add("orientation", getOrientationIcon(), "Change orientation", -1, "", this); theActionManager.add("displaysettings", ThemeManager.getEmptyIcon(ICON_SIZE.TINY), "Change structure display settings", KeyEvent.VK_S, "", this); theActionManager.add("reportsettings", ThemeManager.getEmptyIcon(ICON_SIZE.TINY), "Change report display settings", KeyEvent.VK_R, "", this); }
From source file:ListCutPaste.java
/** * Create an Edit menu to support cut/copy/paste. *//*w w w . ja v a2s .c o m*/ public JMenuBar createMenuBar() { JMenuItem menuItem = null; JMenuBar menuBar = new JMenuBar(); JMenu mainMenu = new JMenu("Edit"); mainMenu.setMnemonic(KeyEvent.VK_E); TransferActionListener actionListener = new TransferActionListener(); menuItem = new JMenuItem("Cut"); menuItem.setActionCommand((String) TransferHandler.getCutAction().getValue(Action.NAME)); menuItem.addActionListener(actionListener); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_T); mainMenu.add(menuItem); menuItem = new JMenuItem("Copy"); menuItem.setActionCommand((String) TransferHandler.getCopyAction().getValue(Action.NAME)); menuItem.addActionListener(actionListener); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_C); mainMenu.add(menuItem); menuItem = new JMenuItem("Paste"); menuItem.setActionCommand((String) TransferHandler.getPasteAction().getValue(Action.NAME)); menuItem.addActionListener(actionListener); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_P); mainMenu.add(menuItem); menuBar.add(mainMenu); return menuBar; }
From source file:electroStaticUI.ElectroStaticUIContainer.java
private void buildFileMenu() { //create Exit menu item exitItem = new JMenuItem("Exit"); exitItem.setMnemonic(KeyEvent.VK_X); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0);/*from ww w. j a va2 s. co m*/ } }); //open open = new JMenuItem("Open"); open.setMnemonic(KeyEvent.VK_P); open.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fChooser = new JFileChooser(); int status = fChooser.showSaveDialog(null); } }); //close close = new JMenuItem("Close"); close.setMnemonic(KeyEvent.VK_C); //export export = new JMenuItem("Export"); export.setMnemonic(KeyEvent.VK_E); export.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fChooser = new JFileChooser(); fChooser.setMultiSelectionEnabled(false); fChooser.setAcceptAllFileFilterUsed(false); FileNameExtensionFilter svgFilter = new FileNameExtensionFilter("Save Vector Plot(svg)", ".svg"); FileNameExtensionFilter pngFilter = new FileNameExtensionFilter("Save Voltage Surface Plot(png)", ".png"); fChooser.addChoosableFileFilter(svgFilter); fChooser.addChoosableFileFilter(pngFilter); fChooser.setFileFilter(svgFilter); int status = fChooser.showSaveDialog(rootPane); if (status == JFileChooser.APPROVE_OPTION) { if (fChooser.getFileFilter() == svgFilter) { try { saveAsName = fChooser.getSelectedFile().getCanonicalPath(); Save.saveChartToSVG(DefaultValues.getChartToSave(), saveAsName, displayPanel.getWidth(), displayPanel.getHeight()); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else if (fChooser.getFileFilter() == pngFilter) { try { saveAsName = fChooser.getSelectedFile().getCanonicalPath(); Save.saveChart3dToPNG(DefaultValues.get3dChartToSave(), saveAsName); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } } }); //save save = new JMenuItem("Save"); save.setMnemonic(KeyEvent.VK_S); save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fChooser = new JFileChooser(); int status = fChooser.showSaveDialog(null); if (status == JFileChooser.APPROVE_OPTION) { try { System.out.println("Height: " + displayPanel.getWidth()); System.out.println("Width: " + displayPanel.getHeight()); saveAsName = fChooser.getSelectedFile().getCanonicalPath(); Save.saveChartToSVG(DefaultValues.getChartToSave(), saveAsName, displayPanel.getWidth(), displayPanel.getHeight()); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } }); //saveAs saveAs = new JMenuItem("Save As"); saveAs.setMnemonic(KeyEvent.VK_A); saveAs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fChooser = new JFileChooser(); int status = fChooser.showSaveDialog(null); if (status == JFileChooser.APPROVE_OPTION) try { System.out.println("Height: " + displayPanel.getWidth()); System.out.println("Width: " + displayPanel.getHeight()); saveAsName = fChooser.getSelectedFile().getCanonicalPath(); System.out.println(saveAsName); Save.saveChartToSVG(DefaultValues.getChartToSave(), saveAsName, displayPanel.getWidth(), displayPanel.getHeight()); } catch (IOException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } try { Save.saveChartToSVG(UserInput.getElectricFieldChart(), saveAsName, displayPanel.getWidth(), displayPanel.getHeight()); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); //JMenu object for file menu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); //fileMenu.add(newFile); //fileMenu.add(open); //fileMenu.add(close); fileMenu.add(export); //fileMenu.add(save); //fileMenu.add(saveAs); fileMenu.add(exitItem); }
From source file:DragPictureDemo2.java
public JMenuBar createMenuBar() { JMenuItem menuItem = null;// w w w . j a v a2 s . c o m JMenuBar menuBar = new JMenuBar(); JMenu mainMenu = new JMenu("Edit"); mainMenu.setMnemonic(KeyEvent.VK_E); TransferActionListener actionListener = new TransferActionListener(); menuItem = new JMenuItem("Cut"); menuItem.setActionCommand((String) TransferHandler.getCutAction().getValue(Action.NAME)); menuItem.addActionListener(actionListener); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_T); mainMenu.add(menuItem); menuItem = new JMenuItem("Copy"); menuItem.setActionCommand((String) TransferHandler.getCopyAction().getValue(Action.NAME)); menuItem.addActionListener(actionListener); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_C); mainMenu.add(menuItem); menuItem = new JMenuItem("Paste"); menuItem.setActionCommand((String) TransferHandler.getPasteAction().getValue(Action.NAME)); menuItem.addActionListener(actionListener); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_P); mainMenu.add(menuItem); menuBar.add(mainMenu); return menuBar; }
From source file:ee.ioc.cs.vsle.editor.Editor.java
/** * Build menu.// w w w . j a v a 2 s . c o m */ public void makeMenu() { JMenuItem menuItem; JMenu menu; JMenu submenu; menuBar = new JMenuBar(); setJMenuBar(menuBar); menu = new JMenu(Menu.MENU_FILE); menu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem(Menu.NEW_SCHEME, KeyEvent.VK_N); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Menu.LOAD_SCHEME, KeyEvent.VK_O); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); menu.add(menuItem); menuItem = new JMenuItem(Menu.RELOAD_SCHEME, KeyEvent.VK_R); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK)); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Menu.SAVE_SCHEME, KeyEvent.VK_S); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); menu.add(menuItem); menuItem = new JMenuItem(Menu.SAVE_SCHEME_AS); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Menu.DELETE_SCHEME, KeyEvent.VK_D); menuItem.addActionListener(getActionListener()); menu.add(menuItem); submenu = new JMenu(Menu.EXPORT_MENU); menu.add(submenu); //submenu.setMnemonic( KeyEvent.VK_E ); SchemeExporter.makeSchemeExportMenu(submenu, getActionListener()); // Export window graphics submenu.add(GraphicsExporter.getExportMenu()); menu.addSeparator(); menuItem = new JMenuItem(Menu.PRINT, KeyEvent.VK_P); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK)); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Menu.EXIT, KeyEvent.VK_X); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuBar.add(menu); menu = new JMenu(Menu.MENU_EDIT); menu.setMnemonic(KeyEvent.VK_E); menu.add(undoAction); menu.add(redoAction); menu.add(cloneAction); menuItem = new JMenuItem(Menu.SCHEME_FIND, KeyEvent.VK_F); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK)); menu.add(menuItem); menuItem = new JMenuItem(Menu.SELECT_ALL, KeyEvent.VK_A); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK)); menu.add(menuItem); menuItem = new JMenuItem(Menu.CLEAR_ALL, KeyEvent.VK_C); menuItem.addActionListener(getActionListener()); menu.add(menuItem); final JCheckBoxMenuItem painterEnabled = new JCheckBoxMenuItem(Menu.CLASSPAINTER, true); painterEnabled.addActionListener(getActionListener()); menu.add(painterEnabled); menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuCanceled(PopupMenuEvent e) { // ignore } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // ignore } @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { Canvas canvas = Editor.getInstance().getCurrentCanvas(); if (canvas == null || !canvas.getPackage().hasPainters()) { painterEnabled.setVisible(false); } else { painterEnabled.setVisible(true); painterEnabled.setSelected(canvas.isEnableClassPainter()); } } }); menuBar.add(menu); menu = new JMenu(Menu.MENU_VIEW); menu.setMnemonic(KeyEvent.VK_V); gridCheckBox = new JCheckBoxMenuItem(Menu.GRID, RuntimeProperties.isShowGrid()); gridCheckBox.setMnemonic('G'); gridCheckBox.addActionListener(getActionListener()); menu.add(gridCheckBox); ctrlCheckBox = new JCheckBoxMenuItem(Menu.CONTROL_PANEL, RuntimeProperties.isShowControls()); ctrlCheckBox.setMnemonic('C'); ctrlCheckBox.addActionListener(getActionListener()); menu.add(ctrlCheckBox); showPortCheckBox = new JCheckBoxMenuItem(Menu.SHOW_PORTS, true); showPortCheckBox.addActionListener(getActionListener()); menu.add(showPortCheckBox); showObjectNamesCheckBox = new JCheckBoxMenuItem(Menu.SHOW_NAMES, false); showObjectNamesCheckBox.addActionListener(getActionListener()); menu.add(showObjectNamesCheckBox); //sync View with current canvas menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { Canvas canvas; if ((canvas = getCurrentCanvas()) == null) return; gridCheckBox.setSelected(canvas.isGridVisible()); ctrlCheckBox.setSelected(canvas.isCtrlPanelVisible()); showPortCheckBox.setSelected(canvas.isDrawPorts()); showObjectNamesCheckBox.setSelected(canvas.isShowObjectNames()); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // ignore } @Override public void popupMenuCanceled(PopupMenuEvent e) { // ignore } }); menuBar.add(menu); menu = new JMenu(Menu.MENU_PACKAGE); menu.setMnemonic(KeyEvent.VK_P); menuItem = new JMenuItem(Menu.LOAD, KeyEvent.VK_L); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuItem = new JMenuItem(Menu.RELOAD, KeyEvent.VK_R); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuItem = new JMenuItem(Menu.INFO, KeyEvent.VK_I); menuItem.addActionListener(getActionListener()); menu.add(menuItem); if (Desktop.isDesktopSupported()) { menuItem = new JMenuItem(Menu.BROWSE_PACKAGE, KeyEvent.VK_B); menuItem.addActionListener(getActionListener()); menu.add(menuItem); } menuItem = new JMenuItem(Menu.CLOSE, KeyEvent.VK_C); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuItem = new JMenuItem(Menu.CLOSE_ALL); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuBar.add(menu); menu.add(new JSeparator()); final JMenu submenuRecent = new JMenu(Menu.RECENT); submenuRecent.getPopupMenu().addPopupMenuListener(new PopupMenuListener() { final JMenuItem empty = new JMenuItem("Empty"); @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { makeRecentSubMenu(submenuRecent); if (submenuRecent.getMenuComponentCount() == 0) { submenuRecent.add(empty); empty.setEnabled(false); } else { if (!((submenuRecent.getMenuComponentCount() == 1) && (submenuRecent.getPopupMenu().getComponentIndex(empty) >= -1))) { submenuRecent.remove(empty); } } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // ignore } @Override public void popupMenuCanceled(PopupMenuEvent e) { // ignore } }); menu.add(submenuRecent); final JMenu menuScheme = new JMenu(Menu.MENU_SCHEME); menuScheme.setMnemonic(KeyEvent.VK_S); makeSchemeMenu(menuScheme); menuScheme.getPopupMenu().addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { makeSchemeMenu(menuScheme); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // ignore } @Override public void popupMenuCanceled(PopupMenuEvent e) { // ignore } }); /* * menuItem = new JMenuItem("Planner"); * menuItem.addActionListener(aListener); menuScheme.add(menuItem); * menuItem = new JMenuItem("Plan, compile, run"); * menuItem.setActionCommand("Run"); * menuItem.addActionListener(aListener); menuScheme.add(menuItem); */ // menuScheme.setMnemonic(KeyEvent.VK_A); menuBar.add(menuScheme); menu = new JMenu(Menu.MENU_OPTIONS); menu.setMnemonic(KeyEvent.VK_O); menuItem = new JMenuItem(Menu.SETTINGS, KeyEvent.VK_S); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, ActionEvent.CTRL_MASK)); menu.add(menuItem); menuItem = new JMenuItem(Menu.FONTS); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuItem = new JMenuItem(Menu.SAVE_SETTINGS); menuItem.addActionListener(getActionListener()); menu.add(menuItem); submenu = new JMenu(Menu.MENU_LAF); submenu.setMnemonic(KeyEvent.VK_L); Look.getInstance().createMenuItems(submenu); menu.add(submenu); menuBar.add(menu); makeToolsMenu(menuBar); menu = new JMenu(Menu.MENU_HELP); menu.setMnemonic(KeyEvent.VK_H); menuBar.add(menu); menuItem = new JMenuItem(Menu.DOCS, KeyEvent.VK_D); menuItem.addActionListener(getActionListener()); menu.add(menuItem); }
From source file:bio.gcat.gui.BDATool.java
public BDATool() { super("BDA Tool - " + AnalysisTool.NAME); setIconImage(getImage("bda")); setMinimumSize(new Dimension(660, 400)); setPreferredSize(new Dimension(1020, 400)); setSize(getPreferredSize());/* w w w . j a v a 2 s .com*/ setLocationByPlatform(true); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); menubar = new JMenuBar(); menu = new JMenu[4]; menubar.add(menu[0] = new JMenu("File")); menubar.add(menu[1] = new JMenu("Edit")); menubar.add(menu[2] = new JMenu("Window")); menubar.add(menu[3] = new JMenu("Help")); setJMenuBar(menubar); menu[0].add(createMenuItem("Open...", "folder-horizontal-open", KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK), ACTION_OPEN, this)); menu[0].add(createMenuItem("Save As...", "disk--arrow", KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK), ACTION_SAVE_AS, this)); menu[0].add(createSeparator()); menu[0].add(createMenuItem("Close Window", "cross", ACTION_CLOSE, this)); menu[1].add(createMenuText("Binary Dichotomic Algorithm:")); menu[1].add(createMenuItem("Add", KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_ADD, this)); menu[1].add(createMenuItem("Edit...", KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_EDIT, this)); menu[1].add( createMenuItem("Remove", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), ACTION_BDA_REMOVE, this)); menu[1].add(createMenuItem("Clear", ACTION_BDAS_CLEAR, this)); menu[1].add(seperateMenuItem(createMenuItem("Move Up", KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_MOVE_UP, this))); menu[1].add(createMenuItem("Move Down", KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_DOWN_MASK), ACTION_BDA_MOVE_DOWN, this)); menu[2].add(createMenuItem("Preferences", ACTION_PREFERENCES, this)); menu[3].add(createMenuItem("About BDA Tool", "bda", ACTION_ABOUT, this)); for (String action : new String[] { ACTION_BDA_EDIT, ACTION_BDA_REMOVE, ACTION_BDAS_CLEAR, ACTION_BDA_MOVE_UP, ACTION_BDA_MOVE_DOWN }) getMenuItem(menubar, action).setEnabled(false); getMenuItem(menubar, ACTION_PREFERENCES).setEnabled(false); registerKeyStroke(getRootPane(), KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "remove", new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (bdaPanel.table.hasFocus()) removeBinaryDichotomicAlgorithm(); } }); toolbar = new JToolBar[1]; toolbar[0] = new JToolBar("File"); toolbar[0].add(createToolbarButton("Open File", "folder-horizontal-open", ACTION_OPEN, this)); toolbar[0].add(createToolbarButton("Save As File", "disk--arrow", ACTION_SAVE_AS, this)); toolbars = new JPanel(new FlowLayout(FlowLayout.LEADING)); for (JToolBar toolbar : toolbar) toolbars.add(toolbar); add(toolbars, BorderLayout.NORTH); add(createSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, true, 360, 0.195, new JScrollPane(bdaPanel = new BinaryDichotomicAlgorithmPanel()), new JScrollPane(tablePanel = new JPanel(new BorderLayout()))), BorderLayout.CENTER); add(bottom = new JPanel(new FlowLayout(FlowLayout.RIGHT)), BorderLayout.SOUTH); status = new JLabel(); status.setBorder(new EmptyBorder(0, 5, 0, 5)); status.setHorizontalAlignment(JLabel.RIGHT); bottom.add(status); ((ListTableModel<?>) bdaPanel.table.getModel()).addListDataListener(this); bdaPanel.table.getSelectionModel().addListSelectionListener(this); revalidateGeneticCodeTable(); }