-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKeyboardHandling.java
More file actions
41 lines (41 loc) · 873 Bytes
/
Copy pathKeyboardHandling.java
File metadata and controls
41 lines (41 loc) · 873 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
import java.awt.*;
import java.awt.event.*;
public class KeyboardHandling extends Frame implements KeyListener
{
Label label;
TextArea textarea;
KeyboardHandling()
{
label = new Label();
label.setBounds(20,40,100,20);
textarea = new TextArea();
textarea.setBounds(20,70,460,310);
textarea.addKeyListener(this);
add(label);
add(textarea);
setSize(500,400);
setLayout(null);
setVisible(true);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent ce)
{
System.exit(0);
}
});
}
public void keyTyped(KeyEvent e)
{
label.setText("Key Typed");
}
public void keyPressed(KeyEvent e)
{
label.setText("Key Presed");
}
public void keyReleased(KeyEvent e) {
label.setText("Key Released");
}
public static void main(String[] args) {
new KeyboardHandling();
}
}