Issue in java.awt.Component.dispatchEvent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

I would like to report an issue in the dispatchEvent() method in base
class java.awt.Component. The JDK API documentation for
dispatchEvent() says:

"Dispatches an event to this component or one of its sub components.
Calls processEvent before returning for 1.1-style events which have
been enabled for the Component."

According to this description, I would expect the attached sample code
(see below) to output this:

 Dispatching action event
 processEvent called

And in fact this is what I get when using the JDK (testing with
OpenJDK 1.6.0_20). However with GNU Classpath I get this:

 Dispatching action event

The processEvent() method is never called.

I looked into the sources and found out that this happens because the
eventTypeEnabled() method in Classpath's implementation of Component
does not know about action events and will always return "false" even
if action events have been (successfully) enabled for the component.

While not an issue when using AWT heavyweight components, this may
break lightweight components that generate action events (which is how
I found this in the first place).


=== Sample code ===
import java.awt.*;
import java.awt.event.ActionEvent;

public class Sample extends Component
{
   protected void processEvent(AWTEvent e)
   {
       System.out.println("processEvent called");
       super.processEvent(e);
   }

   public void simulateActionEvent()
   {
       System.out.println("Dispatching action event");
       enableEvents(AWTEvent.ACTION_EVENT_MASK);
       ActionEvent ev = new ActionEvent(this,
ActionEvent.ACTION_PERFORMED, "test");
       dispatchEvent(ev);
   }

   public static void main(String args[])
   {
       Sample sample = new Sample();
       sample.simulateActionEvent();
   }
}
=== Sample code ===


Best regards,

Guillermo Rodriguez Garcia
guille.rodriguez@xxxxxxxxx


--
Guillermo Rodriguez Garcia
guille.rodriguez@xxxxxxxxx




[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux