-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menu.java
36 lines (29 loc) · 876 Bytes
/
Menu.java
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
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
public class Menu extends JMenuBar implements ActionListener {
JMenu file;
JMenuItem add;
Planner planner;
//Constructor called from the Planner constructor to make the Menubar at the top
public Menu(Planner p){
planner = p;
file = new JMenu("File");
this.add(file);
//Adds the "add" button. You need all these lines to add more menu items
add = new JMenuItem("Add");
add.addActionListener(this);
add.setActionCommand("add");
file.add(add);
}
//When the event calls the ActionCommand "add" , createActivity() is called.
@Override
public void actionPerformed(ActionEvent e) {
String event = e.getActionCommand();
if(event.equals("add")){
planner.createActivity();
}
}
}