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

Reto Merz reto.merz at abacus.ch
Wed Jun 28 12:03:38 UTC 2017


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