@Override public JPopupMenu getComponentPopupMenu() { if (popupMenu == null) { popupMenu = new JPopupMenu(Messages.CHART_COLON); timeRangeMenu = new JMenu(Messages.PLOTTER_TIME_RANGE_MENU); timeRangeMenu.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_TIME_RANGE_MENU)); popupMenu.add(timeRangeMenu); menuRBs = new JRadioButtonMenuItem[rangeNames.length]; ButtonGroup rbGroup = new ButtonGroup(); for (int i = 0; i < rangeNames.length; i++) { menuRBs[i] = new JRadioButtonMenuItem(rangeNames[i]); rbGroup.add(menuRBs[i]); menuRBs[i].addActionListener(this); if (viewRange == rangeValues[i]) { menuRBs[i].setSelected(true); } timeRangeMenu.add(menuRBs[i]); } popupMenu.addSeparator(); saveAsMI = new JMenuItem(Messages.PLOTTER_SAVE_AS_MENU_ITEM); saveAsMI.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_SAVE_AS_MENU_ITEM)); saveAsMI.addActionListener(this); popupMenu.add(saveAsMI); } return popupMenu; }
// arranges the menu bar protected void arrangeMenu() { // Build the first menu. fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu); runMenu = new JMenu("Run"); runMenu.setMnemonic(KeyEvent.VK_R); menuBar.add(runMenu); helpMenu = new JMenu("Help"); helpMenu.setMnemonic(KeyEvent.VK_H); menuBar.add(helpMenu); loadSourceMenuItem = new JMenuItem("Load Source file", KeyEvent.VK_O); loadSourceMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { loadSourceMenuItem_actionPerformed(e); } }); fileMenu.add(loadSourceMenuItem); saveDestMenuItem = new JMenuItem("Save Destination file", KeyEvent.VK_S); saveDestMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { saveDestMenuItem_actionPerformed(e); } }); fileMenu.add(saveDestMenuItem); fileMenu.addSeparator(); exitMenuItem = new JMenuItem("Exit", KeyEvent.VK_X); exitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK)); exitMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { exitMenuItem_actionPerformed(e); } }); fileMenu.add(exitMenuItem); singleStepMenuItem = new JMenuItem("Single Step", KeyEvent.VK_S); singleStepMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { singleStepMenuItem_actionPerformed(e); } }); runMenu.add(singleStepMenuItem); ffwdMenuItem = new JMenuItem("Fast Forward", KeyEvent.VK_F); ffwdMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ffwdMenuItem_actionPerformed(e); } }); runMenu.add(ffwdMenuItem); stopMenuItem = new JMenuItem("Stop", KeyEvent.VK_T); stopMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { stopMenuItem_actionPerformed(e); } }); runMenu.add(stopMenuItem); rewindMenuItem = new JMenuItem("Rewind", KeyEvent.VK_R); rewindMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { rewindMenuItem_actionPerformed(e); } }); runMenu.add(rewindMenuItem); runMenu.addSeparator(); fullTranslationMenuItem = new JMenuItem("Fast Translation", KeyEvent.VK_U); fullTranslationMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { fullTranslationMenuItem_actionPerformed(e); } }); runMenu.add(fullTranslationMenuItem); usageMenuItem = new JMenuItem("Usage", KeyEvent.VK_U); usageMenuItem.setAccelerator(KeyStroke.getKeyStroke("F1")); usageMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { usageMenuItem_actionPerformed(e); } }); helpMenu.add(usageMenuItem); aboutMenuItem = new JMenuItem("About...", KeyEvent.VK_A); aboutMenuItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { aboutMenuItem_actionPerformed(e); } }); helpMenu.add(aboutMenuItem); }