Java 8 MenuBar - 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 MenuBar class.

This code example shows how to use the following methods:add
 */ 
public class AWTMenuBuilderTest { 
    public static void main(String[] argv) {
        final List<Menu> menuList = new ArrayList<Menu>();
        final Frame f = new Frame("AWT Menu Builder Test");
        final MenuBar mb = new MenuBar();
        f.setMenuBar(mb);
 
        Menu m = new Menu("Menu " + (menuList.size() + 1));
        menuList.add(m);
        mb.add(m);
 
        Button addMenu = new Button("Add menu");
        addMenu.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                Menu m = new Menu("Menu " + (menuList.size() + 1));
                menuList.add(m);
                mb.add(m);
            } 
        }); 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:add
    /** 
     * @param title 
     */ 
    public AWTMenuTest(String title) {
        super(title);
        MenuBar mb = new MenuBar();
        mb.add(new Menu("Window"));
        setMenuBar(mb);
    } 
 
    /** 
     * @param args 
     */ 
    public static void main(String[] args) {
        try { 
            final AWTMenuTest wnd = new AWTMenuTest("AWTTest");
            wnd.setVisible(true);
        } catch (Throwable t) {
            t.printStackTrace();
        } 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:add
                2)); 
 
        fMain.setIconImage(imgEmpty);
        fMain.addWindowListener(this);
 
        MenuBar bar = new MenuBar();
 
        // used shortcuts: CERGTSIUDOLM 
        String[] fitems = {
            "-Connect...", "--", "-Open Script...", "-Save Script...", 
            "-Save Result...", "-Save Result csv...", "--", "-Exit" 
        }; 
 
        addMenu(bar, "File", fitems);
 
        String[] vitems = {
            "RRefresh Tree", "--", "GResults in Grid", "TResults in Text", 
            "--", "1Shrink Tree", "2Enlarge Tree", "3Shrink Command", 
            "4Enlarge Command" 
        }; 

4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:add, setHelpMenu
		super("MenuDemo: " + s);
 
		Container cp = this;
		cp.setLayout(new FlowLayout());
 
		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')));

4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getMenu
    super(title, headings, data, w, h);
    index = -1;
    panel = getTextPanel();
 
    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);
  } 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:add
      _senderThread = new Thread(this);
      _senderThread.start();
 
 } 
 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" ) ;

4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:add
 
public class ListenerReuse extends Frame {
	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(); 
			} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 MenuBar Methods: