public class TestPaint 
{
public static void main(String[]args)
{
new TestPaint().init();
}
public void paint(Graphics g)
{
System.out.println("hello");
}
public void init()
{
Frame f = new Frame();
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
f.setSize(300,300);
f.setVisible(true);
f.repaint();
}
}
我的想法是如果把显示的Frame update一下,比如动一下大小或者最大化后还原,程序应该调用paint()方法,所以控制台应该打印hello,不知道我的想法为什么不对,望高手解释,问题有点幼稚,别笑我。