JDK-4648816 : Sometimes focus requests on LW components are delayed
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2002-03-07
  • Updated: 2003-04-12
  • Resolved: 2002-08-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2 mantisFixed
Description

Name: rpR10076			Date: 03/07/2002

###@###.###
Sometimes, if a lightweight component within heavyweight
container receives focus, focus requests to other lightweight
components within the same heavyweight are delayed till next
event arrives.
The problem is demonstrated by included test case, FocusDelay.java.
Start the program, there will be a window with two JButtons and
one JTextField. Click on the JButton titled "Click me!". Its action
listener calls requestFocus() on another JButton and then on the
JTextField. If you don't move the mouse after the click, the focus
will be on JButton titled "Do I have focus?". If you move the mouse,
the focus will move to the JTextField. However, the focus should
move to JTextField without delay.

=================================================================
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class FocusDelay {

    JFrame testFrame;
    JButton testButton1;
    JButton testButton2;
    JTextField testField;

    public FocusDelay() {
        testFrame = new JFrame("See my components!");
        testFrame.setFocusable(true);
        testButton1 = new JButton("Click me!");
        testButton2 = new JButton("Do I have focus?");
        testField = new JTextField("Do I have focus?");
        testButton1.addActionListener(
            new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    testButton2.requestFocus();
                    testField.requestFocus();
                }
            }
        );
        testFrame.getContentPane().setLayout(new FlowLayout());
        testFrame.getContentPane().add(testButton1);
        testFrame.getContentPane().add(testField);
        testFrame.getContentPane().add(testButton2);
    }

    public static void main(String[] args) {
        FocusDelay fd = new FocusDelay();
        fd.testFrame.setSize(300, 100);
        fd.testFrame.setVisible(true);
    }

}
==============================================================
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis mantis-b02 FIXED IN: mantis mantis-b02 INTEGRATED IN: mantis mantis-b02
2004-08-24

EVALUATION Commit to fix in mantis. ###@###.### 2002-03-12
2002-03-12