在以下代码中,无法识别mouseDragged.我做错了什么?
addMouseListener(new MouseInputAdapter() {
@Override
public void mouseDragged(MouseEvent e) { ... }
@Override
public void mousePressed(MouseEvent e) { ... }
});
解决方法:
MouseInputAdapter mia = new MouseInputAdapter() {
@Override
public void mouseDragged(MouseEvent e) { ... }
@Override
public void mousePressed(MouseEvent e) { ... }
};
addMouseListener(mia);
addMouseMotionListener(mia); // <-- You're missing this one.