✔ 最佳答案
你可以用sleep() 去做個animation,我假設你有vector 呢個 idea :
public void draw_circle() {
// compute the direction to move and store in a Point object
// adjust that Point object so that its length is 10 pixels
// compute the new center of the circle
// draw that circle according to the new center
}
public void update_display() {
while (1) {
// clear the screen
if (!circle.center() .equals(mouse_current_pos)) draw_circle();
sleep(1000); // 1000ms = 1s
}
}
public void mouseMoved(MouseEvent e) {
mouse_current_pos = e.getPoint();
}
我相信你會知o的method 放係邊
圖片參考:
http://tw.yimg.com/i/tw/ugc/rte/smiley_1.gif
。你應該要用到MouseMotionListener 呢個Class,你可以去JavaDoc 睇睇點用。