Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Practical No: 10

Name :- Minakshi Sunil Bhavar


Roll no :- 20

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class KeyListenerExample extends Applet implements
KeyListener{
Label l;
TextArea area;
public void init(){

l=new Label();
l.setBounds(20,50,100,20);
area=new TextArea();
area.setBounds(20,80,300, 300);
area.addKeyListener(this);

add(l);add(area);

}
public void keyPressed(KeyEvent e) {
l.setText("Key Pressed");
}
public void keyReleased(KeyEvent e) {
l.setText("Key Released");
}
public void keyTyped(KeyEvent e) {
l.setText("Key Typed");
}

/*<applet code="KeyListenerExample.class" width=400 height=400>


</applet>*/
OUTPUT:

You might also like