-
Notifications
You must be signed in to change notification settings - Fork 0
/
Window.java
50 lines (38 loc) · 1.38 KB
/
Window.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
import java.awt.GridLayout;
import java.awt.event.KeyListener;
import java.util.ArrayList;
import javax.swing.JFrame;
class Window extends JFrame {
private static final long serialVersionUID = -2542001418764869760L;
public static ArrayList<ArrayList<DataOfSquare>> Grid;
public static int width = 20;
public static int height = 20;
public Window() {
// Creates the arraylist that'll contain the threads
Grid = new ArrayList<ArrayList<DataOfSquare>>();
ArrayList<DataOfSquare> data;
for(int i=0;i<width;i++) {
data = new ArrayList<DataOfSquare>();
for(int j = 0; j< height; j++){
DataOfSquare c = new DataOfSquare(2);
data.add (c);
}
Grid.add(data);
}
getContentPane().setLayout(new GridLayout(20,20,0,0));
for(int i=0; i<width; i++){
for(int j=0;j<height;j++){
getContentPane().add(Grid.get(i).get(j).square);
for(int k=0; k<width; k++){
for(int r=0; r<height;r++){
getContentPane().add(Grid.get(i).get(j).square);
}
}
}
}
Tuple position = new Tuple(10,10);
ThreadsController c = new ThreadsController(position);
c.start();
this.addKeyListener((KeyListener) new KeyboardListener());
}
}