class MyPanel extends JPanel implements MouseListener { int x=90; int y=90;
public void paint(Graphics g) { super.paint(g);
// Image img=Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("/coney.png")); // g.drawImage(img, x, y, 117, 117, this);
}
public void mouseClicked(MouseEvent e) { // TODO Auto-generated method stub System.out.print("鼠标点击了"+" "); }
public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub System.out.print("鼠标进来了"+" "); }
public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub System.out.print("鼠标退出了"+" "); }
public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub System.out.print("鼠标按下了"+" "); }
public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub
} } 最后老报错:如下: Exception in thread "main" java.lang.ClassCastException: zhouyong3.MyPanel at java.awt.AWTEventMulticaster.add(Unknown Source) at java.awt.Component.addMouseListener(Unknown Source) at zhouyong3.Test1_4.<init>(Test1_4.java:22) at zhouyong3.Test1_4.main(Test1_4.java:14) 请大侠指点一下,找了半天了.....