import java.awt.Container;

import javax.swing.JOptionPane;

//alt + /  自动补全

//ctrl + shift + f   调整格式
public class FreshThread extends Thread {
	GamePanel p;

	public FreshThread(GamePanel p) {
		this.p = p;// 给类成员属性赋值

	}

	@Override
	public void run() {
		while (!p.isFinish()) {
			p.repaint();// 重新绘制图片
			try {
				Thread.sleep(p.FRESH);
			} catch (InterruptedException e) {
				e.printStackTrace();
			} // 休眠
		}

		Container c = p.getParent();
		while (!(c instanceof MainFrame)) {
			c = c.getParent();
		}
		MainFrame f = (MainFrame) c;

		// 弹出通知
		JOptionPane.showMessageDialog(f, "游戏结束！");
		f.restart();

	}
}
