none
.NET WebBrowser control and a Java applet event handling problems. RRS feed

  • Question

  • I have a Java applet compiled with JDK 1.5.0_02. I'm binding a JPopupMenu object to a JButton, and creating a few JList objects to be displayed in the JPopupMenu. I'm then adding mouse listeners in order to intercept the event and handle it.

    This works fine when I launch the applet standalone in IE. When using the .NET WebBrowser control, however, the EXACT same applet binary will not trigger the event. This applies to the mouseClicked, mousePressed, and mouseReleased event. The mouseExited event will still fire, and clicking the left mouse button WILL cause the JPopupMenu to disappear.

    Does anybody have any idea why this could be happening? Would there be an alternative way to trigger these events that MIGHT be handled correctly? It does seem as though the .NET browser control is consuming the click before it could be handled by the applet, but if that were the case then most/all of the other mouse events shouldn't be working (and the JPopupMenu wouldn't disappear, right?); it only seems to apply to the JList items in a JPopupMenu.

    Could a security issue be blocking the WebBrowser control from dispatching all of the appropriate parts of the mouse message to the applet?

    Here are the Java stack traces in the applet for when the event has been fired:
    WORKING example (standalone, not in WebBrowser control):

    setVisible on PopupMenu hit... b == false
    java.lang.Exception: Stack trace
     at java.lang.Thread.dumpStack(Unknown Source)
     at common.ScrollingPopup.setVisible(ScrollingPopup.java:210)
     at javax.swing.JPopupMenu.menuSelectionChanged(Unknown Source)
     at javax.swing.MenuSelectionManager.setSelectedPath(Unknown Source)
     at javax.swing.MenuSelectionManager.clearSelectedPath(Unknown Source)
     at javax.swing.JPopupMenu.setVisible(Unknown Source)
     at common.ScrollingPopup.setVisible(ScrollingPopup.java:212)
     at javax.swing.JPopupMenu.menuSelectionChanged(Unknown Source)
     at common.ScrollingPopup$2.mouseReleased(ScrollingPopup.java:88)
     at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
     at java.awt.Component.processMouseEvent(Unknown Source)
     at javax.swing.JComponent.processMouseEvent(Unknown Source)
     at common.ScrollingPopup$1.processMouseEvent(ScrollingPopup.java:59)
     at java.awt.Component.processEvent(Unknown Source)
     at java.awt.Container.processEvent(Unknown Source)
     at java.awt.Component.dispatchEventImpl(Unknown Source)
     at java.awt.Container.dispatchEventImpl(Unknown Source)
     at java.awt.Component.dispatchEvent(Unknown Source)
     at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
     at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
     at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
     at java.awt.Container.dispatchEventImpl(Unknown Source)
     at java.awt.Component.dispatchEvent(Unknown Source)
     at java.awt.EventQueue.dispatchEvent(Unknown Source)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.run(Unknown Source)

    NON-WORKING stack trace (note that the chain of events diverges early on, indicating that it had received a different type of message than the standalone. I'm assuming that this has to be a problem somewhere in my WebBrowser control):

    setVisible on PopupMenu hit... b == false
    java.lang.Exception: Stack trace
    at java.lang.Thread.dumpStack(Unknown Source)
    at common.ScrollingPopup.setVisible(ScrollingPopup.java:210)
    at javax.swing.JPopupMenu.menuSelectionChanged(Unknown Source)
    at javax.swing.MenuSelectionManager.setSelectedPath(Unknown Source)
    at javax.swing.MenuSelectionManager.clearSelectedPath(Unknown Source)
    at javax.swing.plaf.basic.BasicPopupMenuUI$MouseGrabber.cancelPopupMenu(Unknown Source)
    at javax.swing.plaf.basic.BasicPopupMenuUI$MouseGrabber.windowDeactivated(Unknown Source)
    at java.awt.AWTEventMulticaster.windowDeactivated(Unknown Source)
    at java.awt.Window.processWindowEvent(Unknown Source)
    at java.awt.Window.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.SentEvent.dispatch(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager$DefaultKeyboardFocusManagerSentEvent.dispatch(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.sendMessage(Unknown Source)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.SequencedEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)


    Has anybody else experienced any similar oddities? I'm at my wit's end here. I sincerely appreciate any and all insight into this issue.

    Thank you,
    Justin Lindh

    Thursday, April 20, 2006 8:20 PM

All replies

  • I'm somewhat convinced that some kind of security issue is affecting this event.

    Could someone please explain to me how to use the WebBrowser with security set to an absolute minumum?

    Friday, April 21, 2006 7:50 PM