JMenu consumes focuslost event in Windows7 LAF Java7

前端 未结 1 602
刺人心
刺人心 2021-01-15 11:07

If a popup menu is still open when another component is clicked, then the component does not get the event, because it\'s probably consumed by the popup. This happens for al

1条回答
  •  感情败类
    2021-01-15 11:30

    Here is the magic line that fixes the problem:

    UIManager.put("PopupMenu.consumeEventOnClose", Boolean.FALSE);
    

    I found this after looking into the source code for the BasicPopupMenuUI class. Apparently this behaviour is a deliberate design choice according to the following comments in the code, but it sure feels like a bug to me.

                // Ask UIManager about should we consume event that closes
                // popup. This made to match native apps behaviour.
    

    By the way, it happens in Java 5 and 6 too.

    0 讨论(0)
提交回复
热议问题