source file name:  TextComponentDemo.java

 import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

  class TextComponentDemo extends JFrame implements ActionListener

     JTextField tf;

   JPasswordField pwf;

   JTextArea ta;

   JFormattedTextField ftf;

       public TextComponentDemo()

 {

            JPanel p= new JPanel(new GridLayout(3, 2, 10, 2));

      p.setBorder(BorderFactory.createTitledBorder("Text Components: "));

       p.add(new JLabel("  JTextField: "));

      tf = new JTextField(10);

      p.add(tf);

p.add(new JLabel("  JPasswordField: "));

      pwf = new JPasswordField(10);

      p.add(pwf);

tf.addActionListener(this);

pwf.addActionListener(this);

      

      p.add(new JLabel("  JFormattedTextField"));

      ftf = new JFormattedTextField(java.util.Calendar

            .getInstance().getTime());

      p.add(ftf);

             ta = new JTextArea("Wel come to DBJ College, Chiplun\n"+

"also to CS department ");

      ta.setFont(new Font("Edwardian Script ITC", Font.ITALIC, 40));

      ta.setLineWrap(true);       

      ta.setWrapStyleWord(true);  

      ta.setBackground(new Color(200, 200, 150)); 

         JScrollPane tAreaScrollPane = new JScrollPane(ta);

      tAreaScrollPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

      tAreaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

      

      Container cp = this.getContentPane();

      cp.setLayout(new BorderLayout(5, 5));

      cp.add(p, BorderLayout.NORTH);

      cp.add(tAreaScrollPane, BorderLayout.CENTER);

 

      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      setTitle("JTextComponent Demo");

      setSize(350, 350);

      setVisible(true);

   }

 public void actionPerformed(ActionEvent e) 

{

System.out.println(e);

if(e.getSource()==tf)

ta.append("\nYou have typed " + tf.getText());

if(e.getSource()==pwf)

ta.append("\nYou password is " + new String(pwf.getPassword()));

         }

 

  

   public static void main(String[] args)

 {

     TextComponentDemo f=new TextComponentDemo();

    f.setTitle("Text Components Program");

    f.setSize(700, 500);

    f.setVisible(true); 

   }

}

output: