-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSpaceInvaders.java
More file actions
41 lines (34 loc) · 1.19 KB
/
SpaceInvaders.java
File metadata and controls
41 lines (34 loc) · 1.19 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
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
@SuppressWarnings("serial")
public class SpaceInvaders extends JFrame {
public SpaceInvaders() {
super("Space Invaders");
Panel panel = new Panel();
add(panel);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
panel.stopTimer();
int result = JOptionPane.showConfirmDialog(SpaceInvaders.this,
"Dare to Quit?");
if (result == JOptionPane.YES_OPTION) {
dispose();
}
}
});
setSize(500,450);
setLocationRelativeTo(null);
setResizable(false);
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
}
public static void main(String[] args)
{
SpaceInvaders s = new SpaceInvaders();
s.setIconImage(new ImageIcon("src/img_invaderbottomA.gif").getImage());
s.setVisible(true);
}
}