United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4648816 : Sometimes focus requests on LW components are delayed

Details
Type:
Bug
Submit Date:
2002-03-07
Status:
Resolved
Updated Date:
2003-04-12
Project Name:
JDK
Resolved Date:
2002-08-08
Component:
client-libs
OS:
generic
Sub-Component:
java.awt
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
1.4.2 (mantis)

Related Reports

Sub Tasks

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



Hardware and Software, Engineered to Work Together