United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4532517 shouldYieldFocus does not allow side effects in 1.4
JDK-4532517 : shouldYieldFocus does not allow side effects in 1.4

Details
Type:
Bug
Submit Date:
2001-11-28
Status:
Resolved
Updated Date:
2003-08-15
Project Name:
JDK
Resolved Date:
2003-08-15
Component:
client-libs
OS:
windows_nt,generic,windows_xp,windows_2000
Sub-Component:
javax.swing
CPU:
x86,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0,1.4.1
Fixed Versions:
5.0 (tiger)

Related Reports
Duplicate:
Duplicate:
Relates:
Relates:

Sub Tasks

Description
shouldYieldFocus does not allow side effects such as popping up a OptionPane.

                                    

Comments
WORK AROUND

    public boolean shouldYieldFocus(JComponent input) {
      if (verify(input)) {
        return true;
      }

      // According to the documentation should yield focus is allowed to cause
      // side effects.  So temporarily remove the input verifier on the text
      // field.
      input.setInputVerifier(null);
      System.out.println("Removed input verifier");

      // Pop up the message dialog.
      String message = "Roll over the 'JButton1' with mouse pointer "
        + "after closing this dialog.\nIt sometimes behaves correctly "
        + "for the first time\n but repeating action brings incorrect "
        + "behaviour of button.";
      JOptionPane.showMessageDialog(null, message , "invalid value", 
        JOptionPane.WARNING_MESSAGE);
      System.out.println("Showed message.");

      // Reinstall the input verifier.
      input.setInputVerifier(this);
      System.out.println("Reinstalled input verifier");

      // Tell whoever called us that we don't want to yeild focus.
      return false;
    }
###@###.### 2001-11-26
                                     
2001-11-26
EVALUATION

Something seems to have changed which is not allowing side-effects in
shouldYieldFocus().  There is a workaround available.  Need to investigate more.
###@###.### 2001-12-05

A typical use case for shouldYieldFocus is to show a dialog.
In 1.4 showing a dialog would result in a focus trasfer and we again
ask the InputVerifier if it shouldYieldFocus which would show another dialog...
The fix is to NOT call into the InputVerifier if we have already called into
the InputVerifier.
###@###.### 2003-08-08
                                     
2003-08-08
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b16


                                     
2004-06-14



Hardware and Software, Engineered to Work Together