/** Return a menu for DesktopWindow and add a special listener. */ public static JMenu getCurrencyMenu(ActionListener listener) { JRadioButtonMenuItem menuItem; String defaultCurrency = Money.getCurrencyFor(Money.getDefaultCurrency()); JMenu menu = new JMenu("Währung"); ButtonGroup group = new ButtonGroup(); JMenu europeanMenu = new JMenu("Europa"); String europeanCurrencies[] = Money.getEuropeanCurrencyList(); for (int i = 0; i < europeanCurrencies.length; i++) { menuItem = new RadioCurrencyMenuItem(europeanCurrencies[i]); menuItem.addActionListener(listener); europeanMenu.add(menuItem); group.add(menuItem); if (europeanCurrencies[i].startsWith(defaultCurrency)) { menuItem.setSelected(true); } if (i == 0) { europeanMenu.addSeparator(); } } menu.add(europeanMenu); return menu; }
protected JMenu buildFileMenu() { JMenu file = new JMenu("File"); JMenuItem newWin = new JMenuItem("New"); JMenuItem open = new JMenuItem("Open"); JMenuItem quit = new JMenuItem("Quit"); newWin.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { newDocument(); } }); open.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { openDocument(); } }); quit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { quit(); } }); file.add(newWin); file.add(open); file.addSeparator(); file.add(quit); return file; }
protected JMenuBar createMenuBar() { JMenuBar bar = new JMenuBar(); JMenu homeMenu = new JMenu("Homing"); bar.add(homeMenu); // adding the appropriate homing options for your endstop configuration for (AxisId axis : AxisId.values()) { Endstops endstops = machine.getDriver().getMachine().getEndstops(axis); if (endstops != null) { if (endstops.hasMin == true) homeMenu.add( makeHomeItem("Home " + axis.name() + " to minimum", EnumSet.of(axis), false)); if (endstops.hasMax == true) homeMenu.add(makeHomeItem("Home " + axis.name() + " to maximum", EnumSet.of(axis), true)); } } /* homeMenu.add(new JSeparator()); homeMenu.add(makeHomeItem("Home XY+",EnumSet.of(Axis.X,Axis.Y),true)); homeMenu.add(makeHomeItem("Home XY-",EnumSet.of(Axis.X,Axis.Y),false)); homeMenu.add(makeHomeItem("Home all+",EnumSet.allOf(Axis.class),true)); homeMenu.add(makeHomeItem("Home all-",EnumSet.allOf(Axis.class),false)); */ return bar; }
/** * Uses the main help menu, and adds a few extra options. If/when there's Android-specific * documentation, we'll switch to that. */ public JMenu buildHelpMenu() { JMenu menu = super.buildHelpMenu(); JMenuItem item; menu.addSeparator(); item = new JMenuItem("Processing for Android Wiki"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Platform.openURL("http://wiki.processing.org/w/Android"); } }); menu.add(item); item = new JMenuItem("Android Developer Site"); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Platform.openURL("http://developer.android.com/"); } }); menu.add(item); return menu; }
public TestSwingExample1() { super("ActionExample"); setChannel(currentChannel); // enable/disable the Actions as appropriate channelLabel.setHorizontalAlignment(JLabel.CENTER); channelLabel.setFont(new Font("Serif", Font.PLAIN, 32)); getContentPane().add(channelLabel, BorderLayout.NORTH); JPanel buttonPanel = new JPanel(new GridLayout(2, 2, 16, 6)); buttonPanel.setBorder(BorderFactory.createEmptyBorder(6, 16, 16, 16)); getContentPane().add(buttonPanel, BorderLayout.CENTER); buttonPanel.add(new JButton(upAction)); buttonPanel.add(new JButton(gotoFavoriteAction)); buttonPanel.add(new JButton(downAction)); buttonPanel.add(new JButton(setFavoriteAction)); JMenuBar mb = new JMenuBar(); JMenu menu = new JMenu("Channel"); menu.add(new JMenuItem(upAction)); menu.add(new JMenuItem(downAction)); menu.addSeparator(); menu.add(new JMenuItem(gotoFavoriteAction)); menu.add(new JMenuItem(setFavoriteAction)); mb.add(menu); setJMenuBar(mb); }
private void createMenu(JFrame frame) { menuBar = new JMenuBar(); // First menu: "File" fileMenu = new JMenu("File"); menuBar.add(fileMenu); newMenuItem = new JMenuItem("New...", KeyEvent.VK_N); newMenuItem.addActionListener(this); fileMenu.add(newMenuItem); saveMenuItem = new JMenuItem("Save...", KeyEvent.VK_S); saveMenuItem.addActionListener(this); fileMenu.add(saveMenuItem); openMenuItem = new JMenuItem("Open...", KeyEvent.VK_O); openMenuItem.addActionListener(this); fileMenu.add(openMenuItem); fileMenu.addSeparator(); exitMenuItem = new JMenuItem("Exit...", KeyEvent.VK_X); exitMenuItem.addActionListener(this); fileMenu.add(exitMenuItem); // Add menubar to frame frame.setJMenuBar(menuBar); }
protected JPopupMenu createPopUpMenu() { JPopupMenu menu = new JPopupMenu(); JMenu saveMenu = new JMenu("Save As.."); menu.add(saveMenu); JMenuItem item = new JMenuItem("PNG"); item.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveImage("PNG"); } }); saveMenu.add(item); item = new JMenuItem("JPEG"); item.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveImage("JPEG"); } }); saveMenu.add(item); JMenu[] menus = createMenus(); if (menus != null) { for (int i = 0; i < menus.length; i++) { menu.add(menus[i]); } } return menu; }
/** Create menus to selct cross-section and spine */ private void initMenus() { JMenuBar menuBar = new JMenuBar(); JMenu crosssectionMenu = new JMenu("Cross-section"); menuBar.add(crosssectionMenu); myCrossSectionSelection = new ButtonGroup(); for (String s : myCrossSections.keySet()) { JMenuItem item = new JRadioButtonMenuItem(s); crosssectionMenu.add(item); myCrossSectionSelection.add(item); item.addItemListener(this); } myCrossSectionSelection.setSelected( myCrossSectionSelection.getElements().nextElement().getModel(), true); JMenu spineMenu = new JMenu("Spine"); menuBar.add(spineMenu); mySpineSelection = new ButtonGroup(); for (String s : mySpines.keySet()) { JMenuItem item = new JRadioButtonMenuItem(s); spineMenu.add(item); mySpineSelection.add(item); item.addItemListener(this); } mySpineSelection.setSelected(mySpineSelection.getElements().nextElement().getModel(), true); setJMenuBar(menuBar); }
public JMenu loadMenu(String title, String[] menutitles) { JMenu menu = new JMenu(title); add(menu); boolean radioButtonMode = false; boolean checkBoxButtonMode = false; boolean firstButton = false; ButtonGroup group = new ButtonGroup(); for (int i = 0; i < menutitles.length; i++) { if (menutitles[i].equals("***")) { menu.add(new JSeparator()); radioButtonMode = false; checkBoxButtonMode = false; } else if (menutitles[i].equals("*rad*")) { radioButtonMode = true; firstButton = true; group = new ButtonGroup(); } else if (menutitles[i].equals("*check*")) { checkBoxButtonMode = true; } else { if (radioButtonMode) { menu.add(radioButton(menutitles[i], group, firstButton)); firstButton = false; } else if (checkBoxButtonMode) { menu.add(checkBoxButton(menutitles[i])); } else { menu.add(menuItem(menutitles[i])); } } } return menu; }
protected void addMenuActions(JMenuBar mb) { JMenu fileMenu = new JMenu("File"); addToMenu(actions.saveAction, fileMenu); addToMenu(actions.saveAsAction, fileMenu); fileMenu.addSeparator(); addToMenu(actions.importAction, fileMenu); addToMenu(actions.exportAction, fileMenu); fileMenu.addSeparator(); addToMenu(actions.exitAction, fileMenu); JMenu editMenu = new JMenu("Edit"); addToMenu(actions.undoAction, editMenu); addToMenu(actions.copyAction, editMenu); addToMenu(actions.pasteAction, editMenu); editMenu.addSeparator(); JMenu selectionMenu = new JMenu("Selection"); for (Action a : actions.layoutActions) addToMenu(a, selectionMenu); editMenu.add(selectionMenu); JMenu viewMenu = new JMenu("View"); JMenu zoomMenu = new JMenu("Zoom"); viewMenu.add(zoomMenu); for (Action a : actions.zoomActions) addToMenu(a, zoomMenu); JMenu helpMenu = new JMenu("Help"); mb.add(fileMenu); mb.add(editMenu); mb.add(viewMenu); mb.add(helpMenu); }
/** * Used to forcibly insert items at the end of the primary menu. Useful if you have items that you * don't want who knows how many levels deep in the more structure. */ public void insertStatic(Component c) { // Determine if the Component can fit already // If yes // Just do a regular insert, we're done. // else // do // Put the standard item closest to the more // menu in the more menu // until the static component (c) can fit in this menu // do a regular insert(component) double componentHeight = c.getPreferredSize().getHeight(); if ((myHeight + componentHeight) < maximumHeight - componentHeight) { // Force the component to go below the moreMenu super.add(c); myHeight += c.getPreferredSize().getHeight(); } else { int itemCount = getMenuComponentCount(); Component componentToMove = null; do { // the standard item is 1 before // the more menu hence -1 int index = getComponentIndex(moreMenu); componentToMove = getComponentAtIndex(index - 1); moreMenu.insert(componentToMove, 0); // super.remove(componentToMove); myHeight -= componentToMove.getPreferredSize().getHeight(); itemCount = getMenuComponentCount(); } while ((componentHeight + myHeight) >= maximumHeight); super.add(c); myHeight += c.getPreferredSize().getHeight(); } }
public Bomberman() { /** * add(new Board()); setTitle("Bomberman"); setDefaultCloseOperation(EXIT_ON_CLOSE); * setSize(600, 550); setLocationRelativeTo(null); setVisible(true); */ JFrame f = new JFrame("Bomberman"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setBounds(50, 50, 500, 545); JMenuBar mb = new JMenuBar(); JMenu m1 = new JMenu("Datei"); mb.add(m1); JMenuItem start = new JMenuItem("Neues Spiel"); m1.add(start); start.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { new Bomberman(); // Bugfix nötig } }); JMenuItem end = new JMenuItem("Beenden"); m1.add(end); end.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { System.exit(1); } }); f.setJMenuBar(mb); f.setLocationRelativeTo(null); f.getContentPane().add(new Board()); f.setVisible(true); }
/** {@inheritDoc} */ @Override public void addMenuItemsWithExpansion( List<JMenuItem> menuItems, JMenu parentMenu, int maxItemsInMenu, ComponentFactory headerItemFactory) { if (menuItems.size() <= maxItemsInMenu) { // Just add them directly for (JMenuItem menuItem : menuItems) parentMenu.add(menuItem); return; } int index = 0; while (index < menuItems.size()) { int toIndex = min(menuItems.size(), index + maxItemsInMenu); if (toIndex == menuItems.size() - 1) // Don't leave a single item left for the last subMenu toIndex--; List<JMenuItem> subList = menuItems.subList(index, toIndex); JMenuItem firstItem = subList.get(0); JMenuItem lastItem = subList.get(subList.size() - 1); JMenu subMenu = new JMenu(firstItem.getText() + " ... " + lastItem.getText()); if (headerItemFactory != null) subMenu.add(headerItemFactory.makeComponent()); for (JMenuItem menuItem : subList) subMenu.add(menuItem); parentMenu.add(subMenu); index = toIndex; } }
public DemoControls(Gradient demo) { super(demo.name); this.demo = demo; JMenuBar inMenuBar = new JMenuBar(); add(inMenuBar); JMenuBar outMenuBar = new JMenuBar(); add(outMenuBar); Font font = new Font("serif", Font.PLAIN, 10); imenu = (JMenu) inMenuBar.add(new JMenu("Inner Color")); imenu.setFont(font); imenu.setIcon(new ColoredSquare(demo.innerC)); omenu = (JMenu) outMenuBar.add(new JMenu("Outer Color")); omenu.setFont(font); omenu.setIcon(new ColoredSquare(demo.outerC)); for (int i = 0; i < colors.length; i++) { squares[i] = new ColoredSquare(colors[i]); innerMI[i] = imenu.add(new JMenuItem(colorName[i])); innerMI[i].setFont(font); innerMI[i].setIcon(squares[i]); innerMI[i].addActionListener(this); outerMI[i] = omenu.add(new JMenuItem(colorName[i])); outerMI[i].setFont(font); outerMI[i].setIcon(squares[i]); outerMI[i].addActionListener(this); } }
/** Set-Up Method to create the file menu */ private void createNewFileMenu() { JMenuItem newBuild; newBuild = new JMenuItem("New Build"); newBuild.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent arg0) { new NewBuildWindow(); } }); JMenuItem saveBuild; saveBuild = new JMenuItem("Save Build"); saveBuild.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent arg0) { try { if (MainWindow.getMainWindow().getLeftPanel().getCurBuild() != null) { try { MainWindow.getMainWindow().getLeftPanel().getCurBuild().writeToDir("res/files/"); } catch (FileAlreadyExistsException e) { int overwrite = JOptionPane.showConfirmDialog( MainWindow.getMainWindow(), "A Build for this Hero already exists in your Directory! Overwrite?"); if (overwrite == 0) { MainWindow.getMainWindow() .getLeftPanel() .getCurBuild() .writeToDirOverwrite("res/files/"); } } } else { JOptionPane.showMessageDialog( MainWindow.getMainWindow(), "You can't save a non-existant Build!"); } } catch (HeadlessException e) { // Can't Happen e.printStackTrace(); } } }); JMenuItem openBuild; openBuild = new JMenuItem("Open Build"); // needs Check for real ItemBuild File openBuild.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent arg0) { final JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File("/res/files")); int returnVal = fc.showOpenDialog(MainWindow.getMainWindow()); if (returnVal == JFileChooser.APPROVE_OPTION) { File opened = fc.getSelectedFile(); MainWindow.getMainWindow().getLeftPanel().addItemBuild(new ItemBuild(opened)); } } }); fileMenu = new JMenu("File"); fileMenu.add(newBuild); fileMenu.add(saveBuild); fileMenu.add(openBuild); }
public void setMenuBar(BeanTableFrame f) { final jmri.util.JmriJFrame finalF = f; // needed for anonymous ActionListener class JMenuBar menuBar = f.getJMenuBar(); JMenu pathMenu = new JMenu("Paths"); menuBar.add(pathMenu); JMenuItem item = new JMenuItem("Delete Paths..."); pathMenu.add(item); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { deletePaths(finalF); } }); JMenu speedMenu = new JMenu("Speeds"); item = new JMenuItem("Defaults..."); speedMenu.add(item); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setDefaultSpeeds(finalF); } }); menuBar.add(speedMenu); }
/** Lay out the elements for the main window */ protected void buildFrame() { GridBagConstraints c = new GridBagConstraints(); GridBagLayout layout = new GridBagLayout(); frame = new JFrame(); menuBar = frame.getJMenuBar(); if (menuBar == null) { menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); } basicListener = new BasicListener(); JMenu menu = new JMenu("File"); JMenuItem readDirectory = new JMenuItem("Read Directory"); readDirectory.addActionListener(basicListener); readDirectory.setActionCommand("READALL"); menu.add(readDirectory); JMenuItem exitProgram = new JMenuItem("ExitProgram"); exitProgram.addActionListener(basicListener); exitProgram.setActionCommand("EXIT"); menu.add(exitProgram); menuBar.add(menu); JPanel panel = new JPanel(); c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 3.0f; panel.setLayout(layout); extraButtonItems(panel, layout); c.weighty = 2.0f; layout.setConstraints(panel, c); frame.add(panel); frame.setSize(400, 400); frame.setVisible(true); }
void windowMenu_menuSelected(MenuEvent e) { // <<TODO:MAINTAINABILITY>> This algorithm is not robust. It assumes // the Window // menu has exactly one "regular" menu item (newWindowMenuItem). [Jon // Aquino] if (windowMenu.getItemCount() > 0 && windowMenu.getItem(0) != null && windowMenu .getItem(0) .getText() .equals(AbstractPlugIn.createName(CloneWindowPlugIn.class))) { JMenuItem newWindowMenuItem = windowMenu.getItem(0); windowMenu.removeAll(); windowMenu.add(newWindowMenuItem); windowMenu.addSeparator(); } else { // ezLink doesn't have a Clone Window menu [Jon Aquino] windowMenu.removeAll(); } // final TaskComponent[] frames = (TaskComponent[]) desktopPane.getAllFrames(); final JInternalFrame[] frames = desktopPane.getAllFrames(); for (int i = 0; i < frames.length; i++) { JMenuItem menuItem = new JMenuItem(); // Increase truncation threshold from 20 to 40, for eziLink [Jon // Aquino] menuItem.setText(GUIUtil.truncateString(frames[i].getTitle(), 40)); associate(menuItem, frames[i]); windowMenu.add(menuItem); } if (windowMenu.getItemCount() == 0) { // For ezLink [Jon Aquino] windowMenu.add(new JMenuItem("(No Windows)")); } }
ManWindow() { try { this.setIconImage(ImageIO.read(new File("ImageMan.png"))); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } label = new JLabel(); mainboard = new ImagePanel(); add(mainboard, BorderLayout.CENTER); collection = new JMenu("图片集"); changeDir = new JMenuItem("进入文件夹"); changeDir.addActionListener(this); collection.add(changeDir); startServer = new JMenuItem("启动"); startServer.addActionListener(this); serverMenu = new JMenu("网络服务"); serverMenu.add(startServer); mainbar = new JMenuBar(); mainbar.add(collection); mainbar.add(serverMenu); setJMenuBar(mainbar); mainview = new ImageThumbView(System.getProperty("user.home"), mainboard, this); add(mainview, BorderLayout.WEST); setBounds(100, 100, 500, 500); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
public MapViewPopup() { entityInfoMenuItem = new JMenuItem("Entity Info"); entityInfoMenuItem.addActionListener(this); add(entityInfoMenuItem); JMenu markerMenu = new JMenu("Marker"); add(markerMenu); createMarkerMenuItem = new JMenuItem("Create"); createMarkerMenuItem.addActionListener(this); markerMenu.add(createMarkerMenuItem); removeMarkerMenuItem = new JMenuItem("Remove"); removeMarkerMenuItem.addActionListener(this); markerMenu.add(removeMarkerMenuItem); loadMarkersMenuItem = new JMenuItem("Load All"); loadMarkersMenuItem.addActionListener(this); markerMenu.add(loadMarkersMenuItem); saveMarkersMenuItem = new JMenuItem("Save All"); saveMarkersMenuItem.addActionListener(this); markerMenu.add(saveMarkersMenuItem); clearMenuItem = new JMenuItem("Clear M&T"); clearMenuItem.addActionListener(this); add(clearMenuItem); functionsMenuItem = new JMenuItem("Functions"); functionsMenuItem.addActionListener(this); add(functionsMenuItem); addSeparator(); debugMenuItem = new JCheckBoxMenuItem("Debug Mode"); debugMenuItem.addActionListener(this); add(debugMenuItem); }
/* * The following method creates the font menu * postcondition: returns the JMenu for the font menu. */ public JMenu createFontMenu() { JMenu menu = new JMenu(new String("Font")); menu.add(createFontNameMenu()); menu.add(createFontSizeMenu()); menu.add(createFontStyleMenu()); return menu; } // end createFontMenu method
public ImageViewerFrame() { logger.entering("ImageViewerFrame", "<init>"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); // set up menu bar JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu menu = new JMenu("File"); menuBar.add(menu); JMenuItem openItem = new JMenuItem("Open"); menu.add(openItem); openItem.addActionListener(new FileOpenListener()); JMenuItem exitItem = new JMenuItem("Exit"); menu.add(exitItem); exitItem.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { logger.fine("Exiting."); System.exit(0); } }); // use a label to display the images label = new JLabel(); add(label); logger.exiting("ImageViewerFrame", "<init>"); }
public JMenuBar getPanelMenuBar() { if (panelMenuBar == null) { JMenuItem menuItem; ICFLibAnyObj container = getSwingContainer(); panelMenuBar = new JMenuBar(); menuAdd = new JMenu("Add"); actionAddSecGroupMember = new ActionAddSecGroupMember(); if (container instanceof ICFSecuritySecGroupObj) { menuItem = new JMenuItem(actionAddSecGroupMember); menuAdd.add(menuItem); } if (getSwingContainer() != null) { panelMenuBar.add(menuAdd); } menuSelected = new JMenu("Selected"); menuSelected.setEnabled(false); actionViewSelected = new ViewSelectedActionSecGroupMember(); menuItem = new JMenuItem(actionViewSelected); menuSelected.add(menuItem); actionEditSelected = new EditSelectedActionSecGroupMember(); menuItem = new JMenuItem(actionEditSelected); menuSelected.add(menuItem); actionDeleteSelected = new DeleteSelectedActionSecGroupMember(); menuItem = new JMenuItem(actionDeleteSelected); menuSelected.add(menuItem); panelMenuBar.add(menuSelected); } return (panelMenuBar); }
/** * Returns a JMenu object for use in the JMenuBar. * * @return JMenu */ private JMenu getFileMenu() { JMenu fileMenu = new JMenu("Fil"); fileMenu.setMnemonic('f'); JMenuItem newImageItem = new JMenuItem("Nytt prosjekt"); newImageItem.setMnemonic('n'); ActionListener newImage = arg0 -> newProject(); newImageItem.addActionListener(newImage); fileMenu.add(newImageItem); JMenuItem openImageItem = new JMenuItem("Åpne prosjekt"); openImageItem.setMnemonic('a'); ActionListener openImage = arg0 -> openProjectDialog(); openImageItem.addActionListener(openImage); fileMenu.add(openImageItem); fileMenu.addSeparator(); JMenuItem exitItem = new JMenuItem("Avslutt"); exitItem.setMnemonic('a'); ActionListener exit = arg0 -> System.exit(0); exitItem.addActionListener(exit); fileMenu.add(exitItem); return fileMenu; }
public JMenuBar getPanelMenuBar() { if (panelMenuBar == null) { JMenuItem menuItem; ICFLibAnyObj container = getSwingContainer(); panelMenuBar = new JMenuBar(); menuAdd = new JMenu("Add"); actionAddMajorVersion = new ActionAddMajorVersion(); if (container instanceof ICFInternetRealProjectObj) { menuItem = new JMenuItem(actionAddMajorVersion); menuAdd.add(menuItem); } actionAddMinorVersion = new ActionAddMinorVersion(); if (container instanceof ICFInternetMajorVersionObj) { menuItem = new JMenuItem(actionAddMinorVersion); menuAdd.add(menuItem); } if (getSwingContainer() != null) { panelMenuBar.add(menuAdd); } menuSelected = new JMenu("Selected"); menuSelected.setEnabled(false); actionViewSelected = new ViewSelectedActionVersion(); menuItem = new JMenuItem(actionViewSelected); menuSelected.add(menuItem); actionEditSelected = new EditSelectedActionVersion(); menuItem = new JMenuItem(actionEditSelected); menuSelected.add(menuItem); actionDeleteSelected = new DeleteSelectedActionVersion(); menuItem = new JMenuItem(actionDeleteSelected); menuSelected.add(menuItem); panelMenuBar.add(menuSelected); } return (panelMenuBar); }
/** * Returns a JMenu object for use in the JMenuBar. * * @return JMenu */ private JMenu getAboutMenu() { JMenu aboutMenu = new JMenu("Om"); aboutMenu.setMnemonic('o'); JMenuItem tipsItem = new JMenuItem("Dagens tips"); tipsItem.setMnemonic('d'); tipsItem.addActionListener(evt -> dailyTips()); JMenuItem aboutItem = new JMenuItem("Om Fargestiften"); aboutItem.setMnemonic('o'); aboutItem.addActionListener( evt -> { AboutDialog about = new AboutDialog(); internalFrameSize = about.getSize(); about.setLocation( (desktopSize.width - internalFrameSize.width) / 2, (desktopSize.height - internalFrameSize.height) / 2); about.setVisible(true); jDesktopPane.add(about, JLayeredPane.MODAL_LAYER); try { about.setSelected(true); } catch (PropertyVetoException e) { e.printStackTrace(); } }); aboutMenu.add(tipsItem); aboutMenu.add(aboutItem); return aboutMenu; }
protected JMenu buildEditMenu() { JMenu edit = new JMenu("Edit"); JMenuItem undo = new JMenuItem("Undo"); JMenuItem copy = new JMenuItem("Copy"); JMenuItem cut = new JMenuItem("Cut"); JMenuItem paste = new JMenuItem("Paste"); JMenuItem prefs = new JMenuItem("Preferences..."); undo.setEnabled(false); copy.setEnabled(false); cut.setEnabled(false); paste.setEnabled(false); prefs.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { openPrefsWindow(); } }); edit.add(undo); edit.addSeparator(); edit.add(cut); edit.add(copy); edit.add(paste); edit.addSeparator(); edit.add(prefs); return edit; }
protected final void initMenu() { mainFrame.setJMenuBar(menuBar); menuBar.add(fileMenu); fileOpen.addActionListener(new FileAddListener()); fileMenu.add(fileOpen); fileClose.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); fileMenu.add(fileClose); // used for language selection, for future add-on /* menuBar.add(languageMenu); eng.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setTextByLocale(new Locale("en", "us")); } }); languageMenu.add(eng); chn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setTextByLocale(new Locale("zh", "cn")); } }); languageMenu.add(chn); */ }
private void addScriptCommandToOmegaT() { JMenu toolsMenu = Core.getMainWindow().getMainMenu().getToolsMenu(); toolsMenu.add(new JSeparator()); JMenuItem scriptMenu = new JMenuItem(); Mnemonics.setLocalizedText(scriptMenu, OStrings.getString("TF_MENU_TOOLS_SCRIPTING")); scriptMenu.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ScriptingWindow.this.setVisible(true); } }); toolsMenu.add(scriptMenu); for (int i = 0; i < NUMBERS_OF_QUICK_SCRIPTS; i++) { JMenuItem menuItem = new JMenuItem(); m_quickMenus[i] = menuItem; String scriptName = Preferences.getPreferenceDefault("scripts_quick_" + scriptKey(i), null); if (scriptName != null || "".equals(scriptName)) { setQuickScriptMenu(new ScriptItem(new File(m_scriptsDirectory, scriptName)), i); } else { unsetQuickScriptMenu(i); } // Since the script is run while editing a segment, the shortcut should not interfere // with the segment content, so we set it to a Function key. m_quickMenus[i].setAccelerator(KeyStroke.getKeyStroke("shift ctrl F" + (i + 1))); toolsMenu.add(menuItem); } }
/** * Create default File menu * * @param menuBar Menu bar to be populated * @param wi WindowInterface where this menu will appear as part of the menu bar */ protected void fileMenu(JMenuBar menuBar, WindowInterface wi) { JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile")); menuBar.add(fileMenu); fileMenu.add( new PrintDecoderListAction( Bundle.getMessage("MenuPrintDecoderDefinitions"), wi.getFrame(), false)); fileMenu.add( new PrintDecoderListAction( Bundle.getMessage("MenuPrintPreviewDecoderDefinitions"), wi.getFrame(), true)); // Use Mac OS X native Quit if using Aqua look and feel if (!(SystemType.isMacOSX() && UIManager.getLookAndFeel().isNativeLookAndFeel())) { fileMenu.add(new JSeparator()); fileMenu.add( new AbstractAction(Bundle.getMessage("MenuItemQuit")) { /** */ private static final long serialVersionUID = -3051429826192051394L; @Override public void actionPerformed(ActionEvent e) { handleQuit(); } }); } }