⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tankclient.java

📁 J2SE坦克大战源码 分为24个版本
💻 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 + -