-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRectangles.java
78 lines (60 loc) · 1.8 KB
/
Rectangles.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class Rectangles extends JFrame implements ActionListener {
JFrame jFrame = new JFrame("Game");
Rectangles(){
JTextArea jTextArea = new JTextArea();
jTextArea.append("hej");
jTextArea.setVisible(true);
this.jFrame.add(jTextArea);
this.jFrame.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
System.out.println(1);
if (e.getKeyCode() == KeyEvent.VK_LEFT){
jTextArea.append("key typed");
System.out.println(1);
}
}
@Override
public void keyPressed(KeyEvent e) {
System.out.println(2);
if (e.getKeyCode() == KeyEvent.VK_LEFT){
jTextArea.append("Nu går du höger");
System.out.println(2);
}
}
@Override
public void keyReleased(KeyEvent e) {
System.out.println(3);
if (e.getKeyCode() == KeyEvent.VK_LEFT){
jTextArea.append("Nu går du höger");
System.out.println(3);
}
}
});
this.jFrame.setVisible(true);
this.jFrame.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent e) {
}
public static void main(String[] args) {
new Rectangles();
}
}
/*
public class Cell {
}
public class Maze {
private Cell[][] cells;
//...
private Cell getCellAt(int x, int y){
return null;
}
}
*/