forked from deepdalsania/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenubar.java
More file actions
52 lines (38 loc) · 960 Bytes
/
Menubar.java
File metadata and controls
52 lines (38 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package applet;
import java.awt.Frame;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.MenuItem;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
@SuppressWarnings("serial")
public class Menubar extends Frame{
Frame f;
public Menubar(){
f = new Frame("Frame");
MenuBar mb = new MenuBar();
Menu m = new Menu("File");
Menu sb = new Menu("Save");
m.add(new MenuItem("New"));
m.add(new MenuItem("Open"));
sb.add(new MenuItem("SaveAs"));
sb.add(new MenuItem("SaveAll"));
m.add(sb);
m.add(new MenuItem("Print"));
m.add(new MenuItem("Refresh"));
m.add(new MenuItem("Exit"));
mb.add(m);
f.setMenuBar(mb);
f.setSize(300, 300);
f.setLocale(null);
f.setVisible(true);
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we) {
f.dispose();
}
});
}
public static void main(String[] args) {
new Menubar();
}
}