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
package game;

import java.awt.Dimension;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class Game extends JPanel {

    private static Dimension screendim = new Dimension(500, 500);

    public Game(int speed1, int speed2) {
	initPanel();
    }

    private void initPanel() {
	setLocation(0, 0);
	setSize(screendim);
	setFocusable(true);
	addKeyListener(new KeyListener() {

	    @Override
	    public void keyPressed(KeyEvent arg0) {
		System.out.println("worked");
	    }

	    @Override
	    public void keyReleased(KeyEvent e) {
	    }

	    @Override
	    public void keyTyped(KeyEvent e) {
	    }

	    
	});
	setFocusable(true);
	requestFocus();
	setDoubleBuffered(true);
    }


}

This paste never expires. View raw. Pasted through import.