- import java.awt.*;
- import java.awt.event.*;
- import java.applet.*;
- /*
- <applet code="KeyEvents.class" height=500 width=600>
- </applet>
- */
- public class KeyEvents extends Applet implements KeyListener {
- int x = 20, y = 30;
- String msg = " ";
- public void init() {
- addKeyListener(this);
- setBackground(Color.green);
- setForeground(Color.blue);
- }
- public void keyPressed(KeyEvent k) {
- showStatus("Key Down");
- }
- public void keyReleased(KeyEvent k) {
- showStatus("Key Up");
- }
- public void keyTyped(KeyEvent k) {
- msg += k.getKeyChar();
- repaint();
- }
- public void paint(Graphics g) {
- g.drawString(msg, x, y);
- }
- }
[text] hii
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: