62,614
社区成员
发帖
与我相关
我的任务
分享
import java.awt.Graphics;
import javax.swing.JFrame;
public class Test extends JFrame
{
public Test()
{
this.setBounds(0, 0, 500, 500);
new Thread( new Runnable()
{
@Override
public void run()
{
while(true)
{
Test.this.repaint();
System.out.println("call repaint");
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}).start();
}
@Override
public void paint(Graphics g)
{
super.paint(g);
System.out.println("call paint");
}
@Override
public void update(Graphics g)
{
System.out.println("call update");
}
public static void main(String[] args)
{
new Test().setVisible(true);
}
}