01坦克大战

1.GUI(Graphics User Interface)图形用户界面         

  AWT(Abstract Window Toolkit)抽象窗口工具集

Component n. 组成部分,部件,成分

2.AWT中核心的是Component类和Container类,Container类继承于Component,但是Container是一类特殊的Component,它代表一种容器,可以盛装普通的Component.

3.匿名类:这种类只用于一个简单的事件处理,可能是只有一个方法待触发执行,没必要花大力气去写成一个完整的类,所以写一个短小精悍的匿名类能让代码更加简洁明了。

 //this是一个Frame类,这个匿名类用了关闭窗口
 //窗口监听加入一个类,现在加入一个匿名类,关闭窗口。
	this.addWindowListener(new WindowAdapter() 
	{
	
		public void windowClosing(WindowEvent e) 
		{
			System.exit(0);
		}
	});

4.Fills an oval bounded by the specified rectangle with the current color.  Oval椭圆,rectangle矩形

	public void paint(Graphics g)
	{
		Color c=g.getColor();
		g.setColor(Color.RED);
		g.fillOval(50, 50, 30, 30);
		//Fills an oval bounded by the specified rectangle 
		//with the current color.
		g.setColor(c);
		
	}

5.paint方法在Component类中,窗口重画是自动调用。

6.屏幕坐标:左上角是原点,x是横轴向右,y是竖轴向下。

猜你喜欢

转载自blog.csdn.net/yan_dan/article/details/81304143
今日推荐