title: multiple dispatchEvent calls on a JButton
body: <p>I have a customized JButton in a Java Swing application. 
  it changes it appearances according to mouse event.<br>
  MouseEvent.MOUSE_ENTERED - will trigger the hover image for the button. MouseEvent.MOUSE_PRESSED - will trigger the pressed image.<br>
  MouseEvent.MOUSE_RELEASED - will change the foreground to gray and render the button disabled.<br>
  This is working fine with actual mouse clicks.</p>
  
  <p>I want to add a support for pressing the ENTER key.<br>
  simply calling <code>button.doClick()</code> did not go through the hover-press-release cycle, but simply jumped to the release event.</p>
  
  <p>So I have this short and effective code for doing this.</p>
  
  <pre><code>InputMap im = workspacePnl.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
  ActionMap am = workspacePnl.getActionMap();
  im.put(KeyStroke.getKeyStroke("ENTER"), "connect");
  am.put("connect", new ConectAction());
  
  private class ConectAction extends AbstractAction {
          @Override
          public void actionPerformed(ActionEvent ev) {
              simulateClick();   
  }
  </code></pre>
  
  <p>and the problematic code:</p>
  
  <pre><code>public void simulateClick() {
          MouseEvent evt;
  
          evt = new MouseEvent(connectBtn,
                  MouseEvent.MOUSE_ENTERED, 1, 0, 0, 0, 1, false);
          connectBtn.dispatchEvent((AWTEvent) evt);
  
          //CommonUtil.sleep(300);
  
           evt = new MouseEvent(connectBtn,
                  MouseEvent.MOUSE_PRESSED, 8, 0, 0, 0, 1, false);
          connectBtn.dispatchEvent((AWTEvent) evt);
  
          //CommonUtil.sleep(300);
  
          evt = new MouseEvent(connectBtn,
                  MouseEvent.MOUSE_RELEASED, 20, 0, 0, 0, 1, false);
          connectBtn.dispatchEvent((AWTEvent) evt);
      }
  </code></pre>
  
  <p>I am trying to make the ENTER press go through the same route:<br> trigger a MOUSE_ENTERED event which will alter the button's appearance for hover, followed by MOUSE_PRESSED and MOUSE_RELEASED.<br>
  But I only see the last event effect. it is as if i'm only firing the last event alone which lacks the liveliness for an interactive software.
  I tried (as can be seen commented out) to have the thread go to sleep after each event firing, but it has no effect.
  If I try to fire each of the other two events they are noticeable on the screen by themselves. it's the batching together that messes things up.</p>
  
  <p>How can I fire a series of dispatchEvents one by one which will all be noticed by the user? how can i make the program wait for the current dispatchEvent to work it's magic before striding on to the next on?</p>
  
  <p>Any help or insights would be greatly appreciated. </p>