日期:2014-05-20  浏览次数:20821 次

HELP!怎么实现绘图中图象的移动???
怎么实现绘图中图象的移动???大哥们帮下忙啊!

------解决方案--------------------
基本结构就是这样的,就是不断的重画图象在拖动的新坐标.
this.addMouseMotionListener(new MouseMotionListener() {
public void mouseDragged(MouseEvent e) {
.................
repaint();
}

public void mouseMoved(MouseEvent e) {
.............
repaint();
}
});

public void paintComponent(Graphics g) {
super.paintComponent(g);

Graphics2D g2D = (Graphics2D) g;
.....
}
}

public void update(Graphics g) {
paint(g);
}
}