title: JOptionPane show message dialog can not be closed in Focus Listener
body: <p>As instructed in the reply to my earlier question I have added focus listener to my text fields.Now the text fields are selected when the tab key is pressed so it is ok. I have a JOPtionPaneShowMessageDialog in the NumberFormattedException handler to inform the user that the text fields should not be left blank. But now when the text field is blank the message appeared as usual, but it can not be closed.When it closed reopened at the same time. How can it rectified.Please help.</p>
  <pre><code>   public void focusLost(FocusEvent ae) {
  }
     public void focusGained(FocusEvent ae) {
         Object source =ae.getSource();
             if(source instanceof JTextField) {
                 gi.selectAll();
                 hra.selectAll();
                 ss.selectAll();
                 pt.selectAll();
  
  '.....code to execute....... '
  
  }else if (source instanceof JButton) ;
      String w= (String) jcb.getSelectedItem();
  try{
      String s1=gi.getText();
          int a=Integer.parseInt(s1);
              String s2=ss.getText();
                  int b=Integer.parseInt(s2);
                      String s3=pt.getText();
                          int f=Integer.parseInt(s3);
                              String s4=sd.getText();
                                  int h=Integer.parseInt(s4);
  '....code to execute....'
  
  }catch(NumberFormatException e) {
      JOptionPane.showMessageDialog(jfrm, &quot;No text field should not be left blank . 
          If no amount in a field put  0 (Zero) .&quot;, &quot;WARNING ! &quot;,1);
      }
  }
  public static void main (String args[]) {
      SwingUtilities.invokeLater(new Runnable() {
          public void run() {
              new IncomeTax();
          }
      });
  }
  }
  
  '''
  
  
  'Also I want to show JOptionpaneShowMessageDialog when the user click on the &quot;Help&quot; JMenuItem.My code for the same is as follows, but it is not working. Please give suggestion for the same also.
  
  '''
  
  }else if (source instanceof JMenuItem) {
       if(ae.getSource()== jmiHelp)
           JOptionPane.showMessageDialog(null,&quot;USER MANUAL\n&quot;+&quot;1.Select Age 
               Group.\n&quot;+&quot;2.Enter Gross Income(Salary/Pension)+Surrender Leave 
               salary+ interest income etc.)\n&quot;+&quot;3.Enter deductions admissible to 
               you.\n&quot;+&quot;4.Look tool tip texts for more details.\n&quot;+&quot;5.Click New 
               Scheme or Old Scheme for the respective tax calculation.\n&quot;+&quot;6.No 
               text fields should not be left blank.If no amount put zero.\n&quot;);
  
  </code></pre>