开发者

please help! how to emulate jre java.awt.MouseEvent in gwt?

开发者 https://www.devze.com 2023-01-18 04:33 出处:网络
i want to em开发者_开发百科ulate java.awt.MouseEvent class, and i defineMouseEvent extends InputEvent which extends java.util.EventObject.

i want to em开发者_开发百科ulate java.awt.MouseEvent class, and i define MouseEvent extends InputEvent which extends java.util.EventObject.

but when i run this in host mode, i got this error, it shows my InputEvent extends ComponentEvent. why? and how can i fix this? thanks!

java.lang.IllegalArgumentException: null source
    at java.util.EventObject.<init>(EventObject.java:38)
    at java.awt.AWTEvent.<init>(AWTEvent.java:279)
    at java.awt.event.ComponentEvent.<init>(ComponentEvent.java:96)
    at java.awt.event.InputEvent.<init>(InputEvent.java:204)
    at java.awt.event.MouseEvent.<init>(MouseEvent.java:548)
    at java.awt.event.MouseEvent.<init>(MouseEvent.java:450)

this situation just happened in host mode, when i compile and deploy it, all work fine.


You're using the wrong event - it should be MouseEvent (from the com.google.gwt.event.dom.client package), the one extending DomEvent<H>. See HasAllMouseHandlers for Widgets implementing all the mouse handlers (or check the individual interfaces for specific use cases).


None of the AWT libraries are part of the GWT emulated JRE libraries. If you want to listen for MouseEvent, you have to add Mouse*Handler to a widget extending FocusWidget. For example, addMouseDownHandler on FocusWidget and it's subclasses. You'll get a MouseEvent when the mouse is pressed over that widget.

0

精彩评论

暂无评论...
验证码 换一张
取 消