Create a simple java Application to write text using KeyListener

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class WritingText extends JFrame implements KeyListener {
    String msg="";
    int x=10,y=20;
    JTextArea txt=new JTextArea();
    public WritingText()
    {
        add(txt);
        txt.setEnabled(false);
        addKeyListener(this);
        setSize(200,300);
        setVisible(true);
    }


    public void keyTyped(KeyEvent e)
    {
        msg+=e.getKeyChar();
        setTitle("Key pressed");
        txt.setText(msg);
    }
    public void keyPressed(KeyEvent e)
    {
        setTitle("Key pressed");

    }
    public void keyReleased(KeyEvent e)
    {
        setTitle("Key Released");

    }

    public static void main(String args[])
    {
        WritingText bt = new WritingText();
        bt.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
    }

}