I have a requirement where I need to replace all the text into "*" (basically masking) at run time entering into jtextArea. Mean to say I am storing the key into a variable at textArea displaying that as "*".
Got a code for that which is as : 

```
public class App {
            String text= "";
            App(){
                JFrame f= new JFrame();
               // final JTextArea area=new JTextArea();
                JTextArea jTextArea=new JTextArea();

                jTextArea.addKeyListener(new KeyListener() {
                public void keyTyped(KeyEvent e) {

                }

                public void keyPressed(KeyEvent e) {

                }

                public void keyReleased(KeyEvent e) {
                   if(Character.isLetter(e.getKeyChar())) {
                  System.out.println(text);
                     //text = text + e.getKeyChar();
                       text += String.valueOf(e.getKeyChar());
                       System.out.println(text);
                       jTextArea.setText(text.replaceAll("[a-z]", "*"));
                   }
                   //System.out.println(text);
               }

            });
                System.out.println(text);
            jTextArea.setBounds(10,30, 200,200);
            jTextArea.setAutoscrolls(true);
            f.add(jTextArea);
            f.setSize(300,300);
            f.setLayout(null);
            f.setVisible(true);
        }
        public static void main(String args[])
        {
            new App();
        }

}

```

Here the problem is its converting my "New line" too and adding that to first line itself.

What my requirement is : 

Input : 

```
Hello

how
are

you

```

**Should appear as :** 

```
*****

***
***

***

```

Kindly advise