Java 8 Menu - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Menu class.

This code example shows how to use the following methods:add
	 
	// constructor 
	StaveActionHandler(Stave stave) {
		theApp = stave;
		 
        noteContextMenu = new PopupMenu();
         
        editNote = new MenuItem("Edit Note");
        editNote.addActionListener(this);
        noteContextMenu.add(editNote );       
         
        repeatNote = new MenuItem("Repeat Note");
        repeatNote.addActionListener(this);
        noteContextMenu.add(repeatNote ); 		
         
        makeRest = new MenuItem("Change to Rest");
        makeRest.addActionListener(this);
        noteContextMenu.add(makeRest);       
         
        deleteNote = new MenuItem("Delete Note");

5
CodeRank
This code example shows how to use the following methods:add
            "-Dump", "-Restore", "-Transfer" 
        }; 
 
        addMenu(bar, "Tools", stools);
 
        Menu     hMenu = new Menu("Help");
        MenuItem aItem = new MenuItem("About");
 
        aItem.setShortcut(new MenuShortcut('A'));
        aItem.addActionListener(this);
        hMenu.add(aItem);
 
        MenuItem hItem = new MenuItem("Help");
 
        hItem.setShortcut(new MenuShortcut('H'));
        hItem.addActionListener(this);
        hMenu.add(hItem);
 
        //bar.add(hMenu); 
        // Command above disabled only until a help display bug is fixed. 

4
CodeRank
This code example shows how to use the following methods:add, addSeparator
		mb = new MenuBar();
		setMenuBar(mb);		// Frame implements MenuContainer
 
		MenuItem mi;
		// The File Menu... 
		fm = new Menu("File");
		fm.add(mi = new MenuItem("Open", new MenuShortcut('O')));
		mi.addActionListener(this);
		fm.add(mi = new MenuItem("Close", new MenuShortcut('W')));
		mi.addActionListener(this);
		fm.addSeparator();
		fm.add(mi = new MenuItem("Print", new MenuShortcut('P')));
		mi.addActionListener(this);
		fm.addSeparator();
		fm.add(mi = new MenuItem("Exit", new MenuShortcut('Q')));
		exitItem = mi;			// save for action handler
		mi.addActionListener(this);
		mb.add(fm);
 
		// The Options Menu... 
4
CodeRank
This code example shows how to use the following methods:add
	public JMenuBar getMenuBar() {
		return menuBar;
	} 
 
	public PopupMenu getTrayIconPopupMenu(ActionListener actionListenr) {
		PopupMenu popup = new PopupMenu();
		trayIconMenuItemExit = new MenuItem("Exit");
		trayIconMenuItemExit.addActionListener(actionListenr);
		popup.add(trayIconMenuItemExit);
 
		return popup;
	} 
 
	/** 
	 * Enable/Disable all menu bar items based on Runner view. 
	 *  
	 * @param mode 
	 */ 
	public void setView(int view) {
 
4
CodeRank
This code example shows how to use the following methods:add
    MenuBar menubar = getMenuBar();
    Menu menu = menubar.getMenu(0);
    MenuItem search = new MenuItem("Search...");
    search.setActionCommand("search");
    search.addActionListener(this);
    menu.add(search);
  } 
 
  // -- ActionListener API methods -- 
 
  public void actionPerformed(ActionEvent e) {
    if ("search".equals(e.getActionCommand())) {
      new SearchBox(this);
    } 
    else panel.actionPerformed(e);
  } 
 
  // -- SearchableWindow API methods -- 
 
  public void selectLine(int index) {
4
CodeRank
This code example shows how to use the following methods:add
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			} 
		}); 
 
		PopupMenu popupMenu = new PopupMenu();
		popupMenu.add(quitMenuItem);
 
		URL imageUrl = this.getClass().getClassLoader().getResource("images/icon.png");
		TrayIcon trayIcon = new TrayIcon(Toolkit.getDefaultToolkit().createImage(imageUrl));
		trayIcon.setImageAutoSize(true);
		trayIcon.setToolTip("WebSocketRemote");
		trayIcon.setPopupMenu(popupMenu);
 
		SystemTray systemTray = java.awt.SystemTray.getSystemTray();
		systemTray.add(trayIcon);
 
		Server server = new Server(40320);
 
		ResourceHandler resourceHandler = new ResourceHandler();
4
CodeRank
This code example shows how to use the following methods:add
 
 } 
 private void installMenu(){ 
      _menuBar      = new MenuBar() ;
 
      _fileMenu     = new Menu( "File" ) ;
 
      _fileMenu.add( _fileExitItem = new MenuItem( "Exit" ) );
      _fileExitItem.addActionListener( this ) ;
      _fileExitItem.setActionCommand( "exit" ) ;
 
      _editMenu     = new Menu( "Edit" ) ;
 
      _editMenu.add( _editEditItem = new MenuItem( "Edit Topology" ) );
      _editEditItem.addActionListener( this ) ;
      _editEditItem.setActionCommand( "edit" ) ;
 
      _widthMenu     = new Menu( "Options" ) ;
 
      _menuBar.add( _fileMenu ) ;
4
CodeRank
This code example shows how to use the following methods:add
	public ListenerReuse() { 
		Button b = new Button("Save");
		add(b);
		MenuBar mb = new MenuBar();
		setMenuBar(mb);
		Menu fm = new Menu("File");
		mb.add(fm);
		MenuItem mi = new MenuItem("Save");
		fm.add(mi);
 
		// Construct the ActionListener, and keep a reference to it. 
		ActionListener saver = new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.out.println("Saving your file...");
				// In real life we would call the doSave() method  
				// in the main class, something like this: 
				// mainProg.doSave(); 
			} 
		}; 
		// Register the actionListener with the Button 
4
CodeRank
This code example shows how to use the following methods:remove
      mediaPlayerControlsVisible = true;
    } 
  } 
   
  public void removeMediaPlayerControls(){ 
    popupMenu.remove(0);
    popupMenu.remove(0);
    popupMenu.remove(0);
    mediaPlayerControlsVisible = false;
  } 
 
 
} 
3
CodeRank
This code example shows how to use the following methods:addNotify, getPeer
    } 
 
    @SuppressWarnings("deprecation") 
    public void addHelpMenu(Menu helpMenu) {
        //TODO provide a workaround for the smissing swing feature, help menu 
        helpMenu.addNotify();
        //jComponent.setHelpMenu(((SwingMenuPeer) helpMenu.getPeer()).jComponent); 
        jComponent.add(((SwingMenuPeer) helpMenu.getPeer()).jComponent);
    } 
 
    @SuppressWarnings("deprecation") 
    public void addMenu(Menu menu) {
        menu.addNotify();
        jComponent.add((JMenu) ((SwingMenuPeer) menu.getPeer()).jComponent);
        jComponent.revalidate(); 
        jComponent.repaint(); 
    } 
} 
4
CodeRank
See Code Examples for Java 8 Menu Methods: