请高手给指点迷津
我写了以下代码:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class j642 extends JApplet // implements ActionListener
{
JPanel touchpanel=new JPanel();
JLabel touchlabel=new JLabel("Active region");
MyMouseListener mml=new MyMouseListener();
MyMouseMotionListener mmml=new MyMouseMotionListener();
public void init()
{
touchlabel.setHorizontalAlignment(SwingConstants.CENTER);
touchpanel.setBackground(Color.white);
touchpanel.add(touchlabel);
touchpanel.addMouseListener(mml);
touchpanel.addMouseMotionListener(mmml);
this.getContentPane().setLayout(new GridLayout(2,0));
this.getContentPane().add(touchpanel);
}
class MyMouseListener extends MouseAdapter
{
public void mouseEntered(MouseEvent e)
{
showStatus("mouse entered the active region");
}
public void mouseExited(MouseEvent e)
{
showStatus("mouse exited the active region");
}
}
class MyMouseMotionListener extends MouseAdapter
{
public void mouseMoved(MouseEvent e)
{
showStatus("mouse moved to location:x:"+e.getX()+"y:"+e.getY());
}
public void mouseDragged(MouseEvent e)
{
showStatus("mouse dragged to location;x;"+e.getX()+"y:"+e.getY());
}
}
}
编译出错:
j642.java [24:1] No method found matching addMouseMotionListener(MyMouseMotionListener)
touchpanel.addMouseMotionListener(mmml);
^
1 error
为什么Class MyMouseListener就没有问题,而类MyMouseMotionListener有问题呢?错误的意思是什么呀?请高手指点