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

我把接口里的方法都实现了,为什么还出现这样的错误
程序出现错误如下:

H:\Java_Test> javac   MyCanvas.java
MyCanvas.java:5:   MyCanvas   is   not   abstract   and   does   not   override   abstract   method
keyTyped(java.awt.event.KeyEvent)   in   java.awt.event.KeyListener
public   class   MyCanvas   implements   KeyListener,MouseListener{
              ^
1   error

源程序如下:
//绘图
import   java.awt.*;
import   java.awt.event.*;
import   java.util.*;
public   class   MyCanvas   implements   KeyListener,MouseListener{
Canvas   c;
String   s   =   " ";
public   static   void   main(String   args[]){
Frame   f   =   new   Frame( "Canvas ");
MyCanvas   mc   =   new   MyCanvas();
mc.c   =   new   Canvas();
f.add( "Center ",mc.c);
f.setSize(150,150);
mc.c.addMouseListener(mc);
mc.c.addKeyListener(mc);
f.setVisible(true);
}

public   void   mouseClicked(MouseEvent   ev){
System.out.println( "MouseClicked ");
c.requestFocus();
}

public   void   KeyTyped(KeyEvent   ev){
System.out.println( "KeyTyped ");
s+=ev.getKeyChar();
c.getGraphics().drawString(s,0,20);
}

public   void   keyPressed(KeyEvent   ev){System.out.println( "KeyPressed ");}
public   void   keyReleased(KeyEvent   ev){System.out.println( "keyReleased ");}
public   void   mousePressed(MouseEvent   ev){System.out.println( "mousePressed ");}
public   void   mouseReleased(MouseEvent   ev){System.out.println( "mouseReleased ");}
public   void   mouseEntered(MouseEvent   ev){System.out.println( "mouseEntered ");}
public   void   mouseExited(MouseEvent   ev){System.out.println( "mouseExited ");}


}

我已经把接口KeyListener,MouseListener里的方法全部实现了,为什么还是出现这样的错误?

------解决方案--------------------
public void keyTyped(java.awt.event.KeyEvent ev){System.out.println( "keyTyped ");}
------解决方案--------------------
KeyTyped的k是小写的
------解决方案--------------------
KeyTyped-->
方法摘要
void keyPressed(KeyEvent e)
按下某个键时调用此方法。
void keyReleased(KeyEvent e)
释放某个键时调用此方法。
void keyTyped(KeyEvent e)
键入某个键时调用此方法。
k大小写拼写错误..