-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNotepadfjava
More file actions
56 lines (54 loc) · 1.22 KB
/
Notepadfjava
File metadata and controls
56 lines (54 loc) · 1.22 KB
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
51
52
53
54
55
56
import java.awt.Dialog;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class MenuBar implements ActionListener{
JMenu file,edit;
JMenuItem cut,copy,paste,Save;
JMenuBar b;
JFrame f;
JTextArea ta;
static Dialog d;
MenuBar(){
f = new JFrame();
d = new Dialog(f , "Dialog Example", true);
cut=new JMenuItem("cut");
copy=new JMenuItem("copy");
paste=new JMenuItem("paste");
Save = new JMenuItem("Save");
Save.addActionListener(this);
cut.addActionListener(this);
copy.addActionListener(this);
paste.addActionListener(this);
b=new JMenuBar();
file=new JMenu("File");
edit=new JMenu("Edit");
file.add(Save);
edit.add(cut);
edit.add(paste);
edit.add(copy);
b.add(file);
b.add(edit);
ta = new JTextArea();
ta.setBounds(5,5,360,320);
f.add(b);
f.add(ta);
f.setJMenuBar(b);
d.setLayout(null);
f.setSize(400,400);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==cut)
ta.cut();
else if(e.getSource()==paste)
ta.paste();
else if(e.getSource()==copy)
ta.copy();
}
}
public class Menu{
public static void main(String args[]) {
new MenuBar();
}
}