import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
//keyevent 类的定义
class mykeylistener implements KeyListener
{
public void keyPreased(KeyEvent evt)
{
showmsg(evt);
}
public void KeyRleased(KeyEvent evt)
{
}
public void KeyTyped(KeyEvent et)
{
}
public void showmsg(KeyEvent evt
{
int code=evt.getKeyCode();
String str=evt.getKeyText(code);
char c=evt.getKeyChar();
if(code!=KeyEvent.VK_UNDEFINED)
System.out.println("the keycode is"+code);
if(c!=KeyEvent.CHAR_UNDEFINED)
System.out.println("the char is"+c);
if(evt.isShiftDown())
System.out.println("the shift is down.");
System.out.println("the key itself is "+str);
}
}
//definition of japanel
class mypanel2 extends JPanel
{
private JTextField tf;
private mykeylistener listener;
public mypanel2()
{
tf=new JTextField(20);
listener =new mykeylistener();
tf.addKeyListener(listener);
add(tf);
}
}
// definition of JFrame
class myframe2 extends JFrame
{
public myframe2()
{
mypanel2 pp2=new mypanel2();
setTitle("jjjjj");
setSize(300,300);
Container pane1=getContentPane();
pane1.add(pp2);
}
}
// the definition of main
public class a2
{
public static void main(String args[])
{
myframe2 fram2 =new myframe2();
fram2.setVisible(true);
}
}
以上的程序编译出了一个错误,:第六行mykeylistener is not abastract and dose not override abstract method keytyped..........
请大家帮帮忙,看一下究竟错在哪里了