-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
45 lines (24 loc) · 789 Bytes
/
Main.java
File metadata and controls
45 lines (24 loc) · 789 Bytes
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
package pong;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.Timer;
import javax.swing.WindowConstants;
class Main {
static JFrame f = new JFrame("pong");
public static void main(String[] args) {
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.setSize(650,515);
PongGame game = new PongGame();
f.add(game);
f.setVisible(true); //Shows the window
Timer timer = new Timer(33, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e){
game.repaint();
game.gameLogic();
}
});
timer.start();
}
}