为什么MouseReleased事件被堆叠(多次)?

时间:2014-12-03 10:48:53

标签: java swing events mouse

应用程序有一个带配置的简短弹出菜单。一段时间后配置增长了,我想调用对话框而不是弹出菜单。但是当我在鼠标事件上调用对话框时,会发生奇怪的事情。 mouseReleased在堆栈中被多次调用。每次调用相同的组件(正确的组件)时,都不是因为从几个重叠的组件调用相同的事件。

看来,我根本无法调用对话而不是弹出菜单,好吧。但是发生了什么?

适配器:

class ConfigTriggerListener extends MouseAdapter{
    ...
    @Override
    public void mouseReleased(MouseEvent ev) {
      if (ev.isPopupTrigger()) {                  <-- breakpoint

        cont.showScreenModal(ConfigDlg.class, DynProps.createFromValues(ConfigDlg.CONFIG_CONTROL_CLASS, ORundownConfig.class));
      }    
    }
}    
右键单击并暂停断点后的

CallStack:

octopus.client.core.rundown.RundownClock$ConfigTriggerListener.mouseReleased(RundownClock.java:164)
java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:290)
java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
java.awt.Component.processMouseEvent(Component.java:6505)
javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
java.awt.Component.processEvent(Component.java:6270)
java.awt.Container.processEvent(Container.java:2229)
java.awt.Component.dispatchEventImpl(Component.java:4861)
java.awt.Container.dispatchEventImpl(Container.java:2287)
java.awt.Component.dispatchEvent(Component.java:4687)
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
java.awt.Container.dispatchEventImpl(Container.java:2273)
java.awt.Window.dispatchEventImpl(Window.java:2719)
java.awt.Component.dispatchEvent(Component.java:4687)
java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
java.awt.EventQueue.access$200(EventQueue.java:103)
java.awt.EventQueue$3.run(EventQueue.java:694)
java.awt.EventQueue$3.run(EventQueue.java:692)
java.security.AccessController.doPrivileged(AccessController.java)
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
java.awt.EventQueue$4.run(EventQueue.java:708)
java.awt.EventQueue$4.run(EventQueue.java:706)
java.security.AccessController.doPrivileged(AccessController.java)
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

0 个答案:

没有答案