📄 tankclient.java
字号:
//0.3
import java.awt.*;
import java.awt.event.*;
public class TankClient extends Frame{
int x = 50;
int y = 50;
public void paint(Graphics g){
Color c = g.getColor();
g.setColor(Color.RED);
g.fillOval(x, y, 30, 30);
g.setColor(c);
y += 1;
x += 1;
}
public void LauchFrame(){
this.setLocation(400, 300);
this.setSize(800, 600);
this.setTitle("坦克大战");
this.setResizable(false);
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
this.setVisible(true);
new Thread(new PaintThread()).start();
}
public static void main(String[] args) {
TankClient tc = new TankClient();
tc.LauchFrame();
}
class PaintThread implements Runnable{
public void run() {
while(true){
repaint();
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -