- 
    Bug 
- 
    Resolution: Fixed
- 
     P3 P3
- 
    1.2.0
- 
        1.1.8
- 
        sparc
- 
        solaris_2.5
- 
        Verified
| Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build | 
|---|---|---|---|---|---|---|
| JDK-2023653 | 1.2.2 | Xianfa Deng | P3 | Resolved | Fixed | 1.2.2 | 
Name: dsC58869 Date: 11/03/98
The method MenuItem.enableEvents(long eventsToEnable) does not allow
subclasses of MenuItem to have the specified event types delivered
to processEvent method regardless of whether a listener is registered.
==== Here is the test demonstrating the bug ====
import java.awt.*;
import java.awt.event.*;
public class TestMenuItem extends MenuItem{
public TestMenuItem (String label) {
super (label);
}
boolean processed = false;
public void processEvent(AWTEvent e) {
processed = true;
}
public static void main (String args[]) {
String item = "Item";
TestMenuItem mi = new TestMenuItem(item);
/* part 1: enable action event */
mi.enableEvents(AWTEvent.ACTION_EVENT_MASK);
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
new ActionEvent(mi, ActionEvent.ACTION_PERFORMED, "Event"));
try { Thread.sleep(10000); } catch (Exception e) {
e.printStackTrace();
}
if (mi.processed) {
System.out.println("OKAY: processEvent invoked");
} else {
System.out.println("FAILED: processEvent not invoked");
}
/* part 2: add and remove listener;
action event enabled */
MyActionListener myal = new MyActionListener();
mi.addActionListener(myal);
mi.removeActionListener(myal);
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(
new ActionEvent(mi, ActionEvent.ACTION_PERFORMED, "Event"));
try { Thread.sleep(10000); } catch (Exception e) {
e.printStackTrace();
}
if (mi.processed) {
System.out.println("OKAY: processEvent invoked");
} else {
System.out.println("FAILED: processEvent not invoked");
}
System.exit(0);
}
}
class MyActionListener implements ActionListener {
public void actionPerformed(ActionEvent e){}
}
==== Here is the output of the test ====
%java -fullversion
java full version "JDK-1.2fcs-P"
%java TestMenuItem
FAILED: processEvent not invoked
OKAY: processEvent invoked
======================================================================
Justification:
The method should work properly
======================================================================
- backported by
- 
                    JDK-2023653 MenuItem.enableEvents(long) works wrong -           
- Resolved
 
-