农民运动讲习所1. Thread and paint()# Java - 爪哇娇娃
g*y
1 楼
Like event-handling code, painting code executes on the
event-dispatching thread. While an event is being handled,
no painting will occur. Similarly, if a painting operation
takes a long time, no events will be handled during that
time.
因此,比如在某个ActionListener里呼叫repaint()是的不到好结果
的,因为同为awt-event-queue Thread, 你的repaint()的不到正确
的执行,尤其是如果在一个loop里呼叫repaint(), 估计只有最后一
个repaint()在ActionListener被执行完后执行。解决的办法只有将
对repaint()的呼叫放在另外一个Thread上,再actionPerform()里呼
叫该方法,这样ActionListener可以很快的执行完,释放awt-event-
queue
event-dispatching thread. While an event is being handled,
no painting will occur. Similarly, if a painting operation
takes a long time, no events will be handled during that
time.
因此,比如在某个ActionListener里呼叫repaint()是的不到好结果
的,因为同为awt-event-queue Thread, 你的repaint()的不到正确
的执行,尤其是如果在一个loop里呼叫repaint(), 估计只有最后一
个repaint()在ActionListener被执行完后执行。解决的办法只有将
对repaint()的呼叫放在另外一个Thread上,再actionPerform()里呼
叫该方法,这样ActionListener可以很快的执行完,释放awt-event-
queue