Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4648816
Votes 3
Synopsis Sometimes focus requests on LW components are delayed
Category java:classes_awt
Reported Against merlin
Release Fixed 1.4.2(mantis)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs
Submit Date 07-MAR-2002
Description



 xxxxx@xxxxx 
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);
    }

}
==============================================================
======================================================================
Work Around
N/A
Evaluation
Commit to fix in mantis.  
 xxxxx@xxxxx  2002-03-12
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang