forked from VenusTokyo/first-year-java-practicals
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTyped.java
More file actions
49 lines (42 loc) · 890 Bytes
/
Typed.java
File metadata and controls
49 lines (42 loc) · 890 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
import java.awt.*;
import java.awt.event.*;
public class Typed extends Frame
{
String msg="";
public Typed()
{
addKeyListener(new MyKeyAdapter(this));
addWindowListener(new MyWindowAdapter6());
}
public void paint(Graphics g)
{
g.drawString(msg, 130, 100);
}
public static void main (String args[])
{
Typed obj=new Typed();
obj.setSize(new Dimension(500,500));
obj.setTitle("Characters you type");
obj.setVisible(true);
}
}
class MyWindowAdapter6 extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}
class MyKeyAdapter extends KeyAdapter
{
Typed help;
public MyKeyAdapter(Typed help)
{
this.help=help;
}
public void keyTyped(KeyEvent ke)
{
help.msg="Typed charecter is: <" +ke.getKeyChar()+" >";
help.repaint();
}
}