Manu

Saturday, November 19, 2016

Write a simple program for Menu and Menu bar.

importjava.applet.Applet;
importjava.awt.Color;
importjava.awt.Frame;
importjava.awt.Menu;
importjava.awt.MenuBar;
importjava.awt.MenuItem;
public class Menuapplet extends Applet
 {
MenuBar mbar;
    Frame frm;
public void init()
    {
frm = new Frame();
frm.setSize(300,400);
frm.setBackground(Color.LIGHT_GRAY);
frm.setVisible(true);
mbar = new MenuBar();
        Menu m = new Menu("File");
m.add(new MenuItem("New"));
m.add(new MenuItem("Open"));
m.add(new MenuItem("Save"));
m.add(new MenuItem("Save as"));
m.add(new MenuItem("Print"));
m.addSeparator();
m.add(new MenuItem("Quit"));
mbar.add(m);
        m = new Menu("Help");
mbar.add(m);
m.add(new MenuItem("Help!!!!"));
m.addSeparator();
m.add(new MenuItem("About!!!!"));
mbar.add(m);       
frm.setMenuBar(mbar);
      }
}

Output :


No comments:

Post a Comment