JDK-6701113 : processFocusEvent not invoked when FocusEvent is posted to event queue
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2008-05-13
  • Updated: 2011-01-19
  • Resolved: 2010-08-12
Related Reports
Relates :  
Description
This is reproducible on Linux and Windows platforms with jdk7 b27 PIT build. Not reproducible with 6u10 b23.

processFocusEvent method of a component is not called when a FocusEvent is dispatched to event queue even after enableEvents is called for the component.

To reproduce:
Run the below test. If a message 'processing focus event' is not printed on console, but is reproduced.

import java.awt.*;
import java.awt.event.*;

public class TestButton extends Button {
    
    public TestButton() {   
        enableEvents(AWTEvent.FOCUS_EVENT_MASK);
    }
	
    public void processFocusEvent(FocusEvent fe) {
        System.out.println("processing focus event");
        System.exit(0);
    }
    
    public static void main(String[] args) {
        TestButton b = new TestButton();
        EventQueue eventQ = new EventQueue();
        FocusEvent focusEvent = new FocusEvent(b, FocusEvent.FOCUS_GAINED);
        eventQ.postEvent(focusEvent);
    }
}

Comments
EVALUATION That's the intentionally made change. Won't fix until severe sonsequences are found.
12-08-2010

EVALUATION After the fix for 6515061 we reject focus events on invisible components. That's why the processFocusEvent method isn't called. Perhaps this is "not a defect"?
29-05-2008