package game; import java.awt.Frame; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class MyFrame extends Frame{ public void launchFrame(){ setTitle("我的游戏"); setSize(ChangLiang.Width,ChangLiang.Height); setLocation(100,100); setVisible(true); new PaintThread().start(); addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }); }class PaintThread extends Thread{ public void run(){ while(true){ repaint(); try { Thread.sleep(50); } catch (InterruptedException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } } } }}