小应用程序有一个按钮和一个文本区,按钮作为发生键盘事件的事件源,并对键盘事件实施监视。程序运行时,先点击按钮,让按钮激活。以后输入英文字母时,在文本区显示输入的字母。
import java. applet.*;import javax. swing.*;
import Java. awt. event.*;
public class Test29 extends Applet implements______
JButton button=new JButton();
JTextArea text=new JTextArea(5,20);
public void init()
button. addKeyListener(this);add(button);add(text);
public void keyPressed(KeyEvent e)
int t=e.______;
if(t>=KeyEvent. VK_A&&t<=KeyEvent. VK_Z)
text. append((char)t+" ");
public void keyTyped(KeyEvent e)
public void keyReleased(KeyEvent e)