谁能告诉我这个程序中paint()函数是如何被调用的?
//=====================DragEvent.java=================import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class DragEvent extends JFrame
{
private int x = -1 , y = -1;
public DragEvent()
{
super("DragEvent.java:鼠标事件测试");
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.add(new Label("拖曳鼠标"),BorderLayout.SOUTH);
addMouseMotionListener(new DragListener());
setSize(400,200);
setVisible(true);
}
class DragListener extends MouseMotionAdapter
{
public void mouseDragged(MouseEvent e)
{
x = e.getX();
y = e.getY();
repaint();
}
}
public void paint(Graphics g)
{
g.fillOval(x, y, 3, 3);
}
public static void main(String args[])
{
DragEvent app = new DragEvent();
app.addWindowListener(new MyWindowListener());
}
}
这个程序中我实在是看不出来paint()函数是在那儿被调用的!各位大大请帮忙看看!
[[it] 本帖最后由 windflowerxj 于 2008-9-2 12:54 编辑 [/it]]