在java的jpanel绘制图形

版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 许可协议。转载请注明出处! https://blog.csdn.net/apersonlikep/article/details/89332284

在java的jpanel绘制图形

使用paint方法,在里面使用super.paint清除之前的残留
在while里使用repaint进行循环绘画

public void display() {
		this.repaint();
	}
	public void paint(Graphics g) {
		super.paint(g);
		dao.drawBackground(g);
		dao.drawState(g, hero);
	}
while(true) {
			start.display();
			try
			{
				Thread.sleep(300);

			}
			catch (InterruptedException e)
			{
				e.printStackTrace();
			}
		}

猜你喜欢

转载自blog.csdn.net/apersonlikep/article/details/89332284