-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTheWorld.java
More file actions
41 lines (35 loc) · 1021 Bytes
/
Copy pathTheWorld.java
File metadata and controls
41 lines (35 loc) · 1021 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
package ood.command.example;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* @author DongZhukai
* @date 14-7-26.
*/
public class TheWorld extends Frame implements ActionListener {
private LetThereBeLandCommand btnLand;
private LetThereBeLightCommand btnLight;
private Panel p;
public TheWorld() throws HeadlessException {
super("This is the world, and God syas ...");
p = new Panel();
p.setBackground(Color.black);
add(p);
btnLand = new LetThereBeLandCommand("Let there be land", p);
btnLight = new LetThereBeLightCommand("Let there be light", p);
p.add(btnLand);
p.add(btnLight);
btnLight.addActionListener(this);
btnLand.addActionListener(this);
setBounds(100,100,400,200);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
CommandFromGod cmd = (CommandFromGod) e.getSource();
cmd.execute();
}
public static void main(String[] args) {
new TheWorld();
}
}