package
menu;
import
java.awt.Frame;
import
java.awt.Menu;
import
java.awt.MenuBar;
import
java.awt.MenuItem;
import
java.awt.event.ActionListener;
public class
MENU extends Frame {
String msg="";
CheckboxMenuItem debug,test;
Frame f= new Frame("Menu and MenuItem
Example");
public
MENU(){
//create MENU BAR add it to frame
MenuBar
mbar=new MenuBar();
setMenuBar(mbar);
//Create Menu items
Menu file=new Menu("File");
MenuItem item1,item2,item3,item4;
file.add(item1=new
MenuItem("New...."));
file.add(item2=new
MenuItem("Edit...."));
file.add(item3=new
MenuItem("View...."));
file.add(item4=new
MenuItem("Quit...."));
mbar.add(file);
Menu Edit=new Menu("Edit");
MenuItem item5,item6,item7,item8;
Edit.add(item5=new
MenuItem("Redo"));
Edit.add(item6=new
MenuItem("Cut"));
Edit.add(item7=new
MenuItem("Copy"));
Edit.add(item8=new
MenuItem("Paste"));
Menu sub=new Menu("Special");
MenuItem item81,item82,item83,item84;
sub.add(item81=new
MenuItem("First"));
sub.add(item81=new
MenuItem("Second"));
sub.add(item81=new
MenuItem("Third"));
sub.add(item81=new
MenuItem("Fourth"));
Edit.add(sub);
//checkable menu items
debug =new
CheckboxMenuItem("Debug");
Edit.add(debug);
test=new
CheckboxMenuItem("Testing");
Edit.add(test);
mbar.add(Edit);
Menu View=new Menu("View");
MenuItem item9,item10,item11,item12;
View.add(item9=new MenuItem("Print Layout"));
View.add(item10=new
MenuItem("Ruler"));
View.add(item11=new
MenuItem("Zoom"));
View.add(item12=new
MenuItem("GridLines"));
mbar.add(View);
f.setMenuBar(mbar);
f.setSize(300,300);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String[] args) {
MENU menu = new MENU();
}
}
OUTPUT:
No comments:
Post a Comment