import java.appleat.*;
import java.awt.*;
import java.awt.event.*;
public class KeyListenerExample extends Applet implements KeyListener{
String pstr="This is your KeyListener class example";
public void init(){
addKeyListener(this);
}
public void keyPressed(KeyEvent e){
showstatus("You have pressed a key");
}
public void keyReleased(KeyEvent e){
showstatus("You have released the key");
}
public void paint(Graphics g){
g.drawString(pstr, 20, 40);
}
public void keyTyped(KeyEvent e){
repaint();
}
}
import java.awt.*;
import java.awt.event.*;
public class KeyListenerExample extends Applet implements KeyListener{
String pstr="This is your KeyListener class example";
public void init(){
addKeyListener(this);
}
public void keyPressed(KeyEvent e){
showstatus("You have pressed a key");
}
public void keyReleased(KeyEvent e){
showstatus("You have released the key");
}
public void paint(Graphics g){
g.drawString(pstr, 20, 40);
}
public void keyTyped(KeyEvent e){
repaint();
}
}
Comments