(c) Alexander Hristov
English Version proofreading and corrections : Jeff Lunt
The next step consists of adding the necessary code in order to make the program terminate when the window
is closed. As usual, we use the WindowClosing event, with a call to System.exit(0) inside
Invaders.java
1 package version02;
2 /**
3 * Curso B?sico de desarrollo de Juegos en Java - Invaders
4 *
5 * (c) 2004 Planetalia S.L. - Todos los derechos reservados. Prohibida su reproducci?n
6 *
7 * http://www.planetalia.com
8 *
9 */
10
11
12 import java.awt.event.WindowAdapter;
13 import java.awt.event.WindowEvent;
14 import javax.swing.JFrame;
15
16 public class Invaders {
17 public static final int WIDTH = 800;
18 public static final int HEIGHT = 600;
19
20 public Invaders() {
21 JFrame ventana = new JFrame("Invaders");
22 ventana.setBounds(0,0,WIDTH,HEIGHT);
23 ventana.setVisible(true);
24 ventana.addWindowListener( new WindowAdapter() {
25 public void windowClosing(WindowEvent e) {
26 System.exit(0);
27 }
28 });