-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKey.java
More file actions
53 lines (38 loc) · 879 Bytes
/
Key.java
File metadata and controls
53 lines (38 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/* <applet code=Key width=600 height=500>
</applet>*/
public class Key extends Applet implements KeyListener
{
int X=40,Y=40;
String msg="KEY EVENTS";
public void init()
{
setBackground(Color.black);
setBackground(Color.white);
addKeyListener(this);
}
public void keyPressed(KeyEvent ke){
msg="KEY PRESSED";
setBackground(Color.white);
showStatus("KeyPressed");
repaint();
}
public void keyRelesed(KeyEvent ke){
msg="KEY RELESED";
setBackground(Color.white);
showStatus("KeyRelesed");
repaint();
}
public void keyTyped(KeyEvent ke){
msg="KEY TYPED";
msg+=ke.getKeyChar();
setBackground(Color.white);
showStatus("KeyTyped");
repaint();
}
public void paint(Graphics gr){
gr.drawString(msg,X,Y);
}
}