displaying the value of variable that is inside while loop on to the TextArea
<p>I am trying to convert speech to text and to display it on an AWT textArea.
But the output in the speech to text converter function is generated inside a while loop and I am unable to display that on the textArea. I am getting a null pointer exception; please someone help.</p>

<pre><code>public class Speechrec  {

    private static TextArea textArea;
    String resultText;
    private String dr;

    public void recognizer(String[] args) {

        try {
            URL url;
            if (args.length &gt; 0) {
                url = new File(args[0]).toURI().toURL();
            } 
            else {
                url = Speechrec.class.getResource("speechrec.config.xml");
            }    
            System.out.println("Loading...");    
            ConfigurationManager cm = new ConfigurationManager(url);    
            Recognizer recognizer = (Recognizer) cm.lookup("recognizer");
            Microphone microphone = (Microphone) cm.lookup("microphone");    
            /* allocate the resource necessary for the recognizer */
            recognizer.allocate();    
            /* the microphone will keep recording until the program exits */
            if (microphone.startRecording()) {    
            System.out.println("Say: some greetings");
            while (true) {
                System.out.println("Start speaking. Press Ctrl-C to quit.\n");

                Result result = recognizer.recognize();

                if (result != null) {
                    String resultText = result.getBestFinalResultNoFiller();            
                    textArea.setText(resultText);
                } 
                else {
                    System.out.println("I can't hear what you said.\n");
                }
            }
            } 
            else {
               System.out.println("Cannot start microphone.");
               recognizer.deallocate();
               System.exit(1);
            }
        } 
        catch (Exception) {                
            // exception handling
        }
    }        

public static void main( final String[] args) throws IOException {
    Speechrec sp1=new Speechrec();      
    Frame frame=new Frame("speech to sign language converter");
    TextArea textarea=new TextArea (05,30);     
    Button button = new Button("Start speaking"); 
    // ...        
    frame.add(button,BorderLayout.SOUTH); 
    // ...
    frame.setLayout(new FlowLayout(FlowLayout.TRAILING,50,15));
    frame.setSize(500,400); 
    frame.setVisible(true);

    button.addActionListener(new ActionListener() {           
         public void actionPerformed(ActionEvent e1) {      
             Speechrec sp=new Speechrec();
         sp.recognizer(args);
          }});
    }    
}
</code></pre>
