JTextField.requestFocus problem

From: Matthew Bailey (mbailey_at_pirho.com)
Date: 07/06/04


Date: Tue, 06 Jul 2004 09:19:31 -0600

I have an applet which contains text fields that need validation on
event focusLost. Everything works perfect until I try to to the
JTextField.requestFocus at which time the Dialog box displays 3 or 4
times and then no longer allows you to edit any text fields.

I don't understand why this is hapenning.

Here is the code I'm using to handle the focusLost event:

public void focusLost(java.awt.event.FocusEvent e) {
                 if (e.isTemporary()) {
                                 return;
             }
                 javax.swing.JTextField textField =
                 (javax.swing.JTextField)e.getSource();
                 String content = textField.getText();

                 if (content.length() != 0) {
                     try {
                         Integer.parseInt(content);
                     } catch (NumberFormatException nfe) {
                         getToolkit().beep();

                             javax.swing.JOptionPane.showMessageDialog(null,
                                 "Invalid Character Entered!\nPlease
enter whole positive numbers only!\nNo alpha characters allowed,
including '#$.([{)]}' ",
                                 "Integer Field Error",
                                 javax.swing.JOptionPane.ERROR_MESSAGE);
                         textField.requestFocus();
                     }
                 }
             }
         });