<AWT Dev> Identify SunDropTargetEvent without instanceof and getClass()

Sergey Bylokhov sergey.bylokhov at oracle.com
Mon Jul 3 18:39:40 UTC 2017

Thank you for the report.
Can you please create a CR via http://bugs.java.com/?

----- reto.merz at abacus.ch wrote:

> Hello,
> Is there a nice way to identify AWTEvent as a SunDropTargetEvent?
> Otherwise would it be possible to introduce a new public "boolean
> isDropTargetEvent()" method on MouseEvent or AWTEvent?
> Or a public static method "boolean isDropTargetEvent(AWTEvent)"
> somewhere?
> At the moment we do this:
>     if
> ("sun.awt.dnd.SunDropTargetEvent".equals(event.getClass().getName()))
> We prefer this over instanceof because of the sun import and java 9.
> Also AWT uses "instanceof SunDropTargetEvent" in several places (eg:
> Component, EventQueue and LightweightDispatcher) to identify
> SunDropTargetEvent.
> We need to this for similar reasons like AWT itself, our custom
> EventQueue implementation needs to identify such events and handle it
> in a different way.
> Thanks
> Reto

More information about the awt-dev mailing list