title: Java Multiple Button Clicks
body: <p>I have 5 buttons on the pannel, named "add", "edit", "delete", "ok", "cancel". Now if I click the cancel button straight away, the form terminates. I have called the <code>dispose()</code> method from the click event.</p>
  
  <p>However, what I want to do is: if I click the add button first and then click the cancel button, the program should get back to the initial state, in spite of terminating, because of <code>dispose()</code>.</p>
  
  <p>How do I do it ?</p>
  
  <p>Here's my add button action event code:</p>
  
  <pre><code>public class TheButtounHandler implements ActionListener
  {
       @Override
       public void actionPerformed(ActionEvent ae) 
       {
           if(ae.getSource().equals(addButton))
           {
               enableDisabledByDefault();
               editButton.setEnabled(false);
               deleteButtoun.setEnabled(false);
               addButton.setEnabled(false);
               if(ae.getSource().equals(cancelButton))
               {
                   disabledByDefault();
               }
           }
           else if(ae.getSource().equals(cancelButton))
           {
               dispose();
           }
       }
  }
  </code></pre>