import java.awt.*;
class Menu{
Frame f;
MenuBar mb;
Menu m1,m2,m3;
MenuItem mn1,mn2,mn3,mn4,mn5,mn6;
Menu() {
f=new Frame();
mb=new MenuBar();
m1=new Menu();
m3=new Menu();
m2=new Menu();
mn1=new MenuItem("new");
mn2=new MenuItem("new");
mn3=new MenuItem("new");
mn4=new MenuItem("new");
mn5=new MenuItem("new");
mn6=new MenuItem("new");
m1.add(mn1);
m1.add(mn2);
m2.add(mn3);
m2.add(mn4);
m3.add(mn5);
m3.add(mn6);
mb.add(m1);
mb.add(m2);
mb.add(m3);
f.setMenuBar(mb);
f.setTitle("menu demo");
f.setVisible(true);
f.setSize(300,300);
}
public static void main(String[] args){
new Menu();
}
}
i am getting an error in adding a menu item to a menu
492 views Asked by user2720828 At
3
You have a conflict there with the name
Menu
. You need to import the proper classes.Useif you want to go with your class name as
Menu
or else change your class name to some other name and import a Menu class.