0% found this document useful (0 votes)
27 views

Mnubr

This document provides an example of how to create menu bars and menus in AWT. It creates a MenuFrame class that extends Frame and adds a menu bar with File and Edit menus. The File menu contains New, Open, and Close menu items. The Edit menu contains cut, copy, paste, and other menu items as well as checkboxes for debug and test options. The class handles window destroy and menu item selection events.

Uploaded by

ckavithabe
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Mnubr

This document provides an example of how to create menu bars and menus in AWT. It creates a MenuFrame class that extends Frame and adds a menu bar with File and Edit menus. The File menu contains New, Open, and Close menu items. The Edit menu contains cut, copy, paste, and other menu items as well as checkboxes for debug and test options. The class handles window destroy and menu item selection events.

Uploaded by

ckavithabe
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Menu Bar And Menus In AWT

Examples programs:

Import java .awt. *;


Import java. applet.*;
Class MenuFrame extends Frame{
String msg = “ “;
Checkboxmenuitem debug,test;
MenuFrame(String title) {
Super(title);
Menubar mbar = new menubar();
SetMenubar(mbar);
Menu file = new Menu(“File”);
File.add(new MenuItem(“New”));
File.add(new MenuItem(“Open”));
File.add(new MenuItem(“Close”));
Mbr.add(file));

Menu edit=new menu(“Edit”);


Edit.add(new MenuItem(“cut”));
Edit.add(new MenuItem(“Copy”));
Edit.add(new MenuItem(“Paste”));
Edit.add(new MenuItem(“Special”));
Edit.add(new menuitem(“first”));
Edit.add(new menuItem(“second”));
Edit.add(new menuitem(“third”));
Edit.add(sub);

Debug=new checkboxmenuitem(“debug”);
Edit.add(debug);
Test=new checkboxmenuitem(“test”);
Edit.add(test);
Mbr.add(edit);
}
Public Boolean handleEvent(Event evtObj){
If(evtObj.id==Event.WINDOW_DESTROY){
Hide();
Return true;
}
Return super.handleEvent(evtObj);
}
Public Boolean action (Event evtObj,Object arg) {
If(evtObj.target instanceof MenuItem) {
Msg=” U selected”;
If(arg.equals(“New..”))
Msg+=”New”;
Elseif(arg.equals(

You might also like