主题:判断‘a’是否按下
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class e4 extends Applet
{
TextArea ta=new TextArea(4,20);
public void init()
{
this.add(ta);
this.addKeyListener(new ka());
}
class ka extends KeyAdapter
{
public void KeyPressed(KeyEvent e)
{
if(e.getKeyCode() == KeyEvent.VK_A)
ta.setText("You have pressed 'a'");
}
}
}
为什么按下a键没有反应?
import java.awt.event.*;
import java.applet.*;
public class e4 extends Applet
{
TextArea ta=new TextArea(4,20);
public void init()
{
this.add(ta);
this.addKeyListener(new ka());
}
class ka extends KeyAdapter
{
public void KeyPressed(KeyEvent e)
{
if(e.getKeyCode() == KeyEvent.VK_A)
ta.setText("You have pressed 'a'");
}
}
}
为什么按下a键没有反应?