-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPingPongApp.java
46 lines (39 loc) · 1.29 KB
/
PingPongApp.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
import javax.swing.*;
import java.awt.*;
/**
* Created with IntelliJ IDEA.
* User: cybercser
* Date: 13-6-26
* Time: 上午10:57
* To change this template use File | Settings | File Templates.
*/
public class PingPongApp extends JApplet implements PingPongConstants {
private Ball ball = new Ball();
public PingPongApp() {
ball.setBorder(BorderFactory.createLineBorder(Color.RED));
setLayout(new BorderLayout());
add(ball, BorderLayout.CENTER);
}
private boolean isStandAlone = false;
public void init() {
setSize(new Dimension(DESK_LENGTH, DESK_WIDTH));
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame("Ping Pong");
PingPongApp applet = new PingPongApp();
applet.isStandAlone = true;
frame.add(applet, BorderLayout.CENTER);
applet.init();
applet.start();
frame.pack();
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
});
}
}