JApplet: setJMenuBar(JMenuBar menuBar) : JApplet « javax.swing « Java by API






JApplet: setJMenuBar(JMenuBar menuBar)

import javax.swing.JApplet;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

public class MenuApplet extends JApplet {
  public void init() {
    JMenuBar menubar = new JMenuBar();

    JMenu menuFile = new JMenu("File");

    JMenuItem openItem = new JMenuItem("Open");
    menuFile.add(openItem);

    JMenuItem saveItem = new JMenuItem("Save");
    menuFile.add(saveItem);

    menubar.add(menuFile);

    JMenu menuHelp = new JMenu("Help");

    JMenuItem aboutItem = new JMenuItem("About");
    menuHelp.add(aboutItem);

    menubar.add(menuHelp);

    setJMenuBar(menubar);
  }
}

           
       








Related examples in the same category

1.JApplet: destroy()
2.JApplet: init()
3.JApplet: paint(Graphics g)
4.JApplet: showStatus(String text)
5.JApplet: start()
6.JApplet: stop()