title: Clearing contents of TextField using setText does not work in AWT
body: <p>I am having problems clearing contents of <code>TextField</code> in AWT using <code>setText()</code> method. Apparently, <code>setText("")</code> does not clear the contents of the <code>TextField</code> on pressing the 'Reset' button. Here's my program:</p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  
  public class form extends Frame
  {
  
      Label lbl = new Label("Name:");
      TextField tf = new TextField();
      Button btn = new Button("Reset");
  
      public form()
      {
          tf.setColumns(20);
  
          addWindowListener(new WindowAdapter()
          {
              public void windowClosing(WindowEvent e)
              {
                  System.exit(0);
              }
          });
  
  
          btn.addActionListener(new ActionListener() 
          {
              public void actionPerformed(ActionEvent e) 
              {
                 tf.setText("");  //Problem occurs here. This does not clear the contents of the text field on pressing the 'Reset' button.
  
              }
          });
  
  
          add(lbl);
          add(tf);
          add(btn);
  
          setLayout(new FlowLayout());
          setSize(400,100);
          setVisible(true);
          setTitle("Form");
  
      }
  
  
      public static void main(String[] args) 
      {
          new form();
      }
  
  }
  </code></pre>
  
  <p>Can someone please tell me where I went wrong or suggest an alternative? Thanks.</p>