如题!求解!!!
附上代码
import java.awt.*;
import java.awt.event.*;
public class TestMouseDrag extends Frame{
TestMouseDrag(){
setBounds(100,100,500,500);
addMouseListener(new MouseAction());
setVisible(true) ;
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public static void main( String args[ ] ){
new TestMouseDrag();
}
private class MouseAction extends MouseAdapter{
public void mouseClicked(MouseEvent e){
System.out.println("clicked!");
}
public void mouseDragged(MouseEvent e){
System.out.println("dragged!");
}
}
}
------解决方案--------------------
在addMouseListener之外还要addMouseMotionListener
------解决方案--------------------
mouseDragged() 是属于 MouseMotionListener的方法 不属于 MouseListener。。