import javax.swing.*;
import java.awt.Graphics;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.util.*;
public class  writeP1 extends JPanel implements ActionListener
{ 
  JLabel label1;
  JTextField sentencebox;
  JPanel inputPanel;
  JTextArea t;
  String sentence;
  
  public writeP1()
  {    	
	label1=new JLabel("enter your sentence : ");
	t=new JTextArea(" ");
	t.setFont(new Font("Serif",Font.BOLD,24));
	sentencebox=new JTextField("Welcome to Java exam                                           ");	
    setLayout(new BorderLayout());
    inputPanel=new JPanel();
    inputPanel.add(label1);
    inputPanel.add(sentencebox);
    add(inputPanel,BorderLayout.NORTH);
    add(t,BorderLayout.CENTER);
    sentencebox.addActionListener(this);
  }
  
public static String enterString(String s)
{        
 StringTokenizer token=new StringTokenizer(s);
 int n=token.countTokens()-1;
 int m=n+1;
 String a="";
 int j=0;           
 while(token.hasMoreTokens())
 {a+=token.nextToken()+"\n";}
  return a;
}
  
  public void actionPerformed( ActionEvent e)
  {
	 if(e.getSource()==sentencebox)
        {   sentence=sentencebox.getText();
	        t.setText(enterString(sentence)); }
     repaint();
  }

}
