home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-03-12 | 650 b | 37 lines |
- import java.awt.*;
- import java.applet.*;
-
- public class KeyApplet extends Applet
- {
- int keyPressed;
-
- public void init()
- {
- keyPressed = -1;
-
- Font font =
- new Font("TimesRoman", Font.BOLD, 144);
- setFont(font);
-
- resize(200, 200);
- }
-
- public void paint(Graphics g)
- {
- String str = "";
-
- if (keyPressed != -1)
- {
- str += (char)keyPressed;
- g.drawString(str, 40, 150);
- }
- }
-
- public boolean keyDown(Event evt, int key)
- {
- keyPressed = key;
- repaint();
- return true;
- }
- }
-