package com.bjsxt;import java.awt.*;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;public class MyGameFrame extends Frame {    Image bg = GameUtil.getImage("images/bg.jpg");    Image plane = GameUtil.getImage("images/plane.png");    int x,y;  // 表示飞机的坐标    // 初始化窗口    public void launchFrame() {        this.setTitle("飞机大战");        this.setVisible(true); // 默认窗口不可见,需要让他可见        this.setSize(500,500);        this.setLocation(300,300);        //增加关闭窗口的动作        this.addWindowListener(new WindowAdapter() {            @Override            public void windowClosing(WindowEvent e) {                System.exit(0);            }        });        // 启动窗口绘制线程        new PaintThread().start();    }    @Override    public void paint(Graphics g) {    //        // g 就是画笔//        Color old = g.getColor();//        g.setColor(Color.blue);////        g.setColor(new Color(0,0,255));////        g.drawLine(100,100,400,400);//直线////        g.drawRect(100,100,400,400); //方形//        g.drawOval(100,100,400,400); //圆形//        g.drawString("str",200,200);  // 文字        System.out.println("窗口绘制");        g.drawImage(bg,0,0,500,500,null);        g.drawImage(plane,x,y,30,30,null);        x--;        y--;    }    // 重画线程    class PaintThread extends Thread {        @Override        public void run() {            while (true){                repaint();                try {                    Thread.sleep(40);  // 1s = 1000ms                } catch (InterruptedException e) {                    e.printStackTrace();                }            }        }    }    public static void main(String[] args) {        MyGameFrame frame = new MyGameFrame();        frame.launchFrame();    }}