0% found this document useful (0 votes)
12 views2 pages

Practical No 10

The document provides a Java program that demonstrates key event handling in an applet window using the KeyListener interface. It captures key pressed, released, and typed events, updating a label with the corresponding messages. The program creates a simple GUI with a frame and a label to display the key event statuses.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Practical No 10

The document provides a Java program that demonstrates key event handling in an applet window using the KeyListener interface. It captures key pressed, released, and typed events, updating a label with the corresponding messages. The program creates a simple GUI with a frame and a label to display the key event statuses.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical No 10: Write a program to demonstrate statys of key on Applet

window such as KeyPressed , KeyRelased , KeyUp ,KeyDown.

import java.awt.Frame;

import java.awt.Label;

import java.awt.LayoutManager;

import java.awt.event.KeyEvent;

import java.awt.event.KeyListener;

public class KeyEventEx1 extends Frame implements KeyListener {

String msg = "";

Label l;

public KeyEventEx1() {

this.addKeyListener(this);

this.l = new Label();

this.l.setBounds(20, 50, 100, 200);

this.add(this.l);

this.setSize(300, 300);

this.setLayout((LayoutManager)null);

this.setVisible(true);

public void keyPressed(KeyEvent var1) {

this.l.setText("KeyPressed");

public void keyReleased(KeyEvent var1) {

this.l.setText("Key Released");

public void keyTyped(KeyEvent var1) {


String var10001 = this.msg;

this.msg = var10001 + var1.getKeyChar();

this.l.setText(this.msg);

public static void main(String[] var0) {

new KeyEventEx1();

OUTPUT:

You might also like