<Swing Dev> RFR: 8048109: JToggleButton does not fire actionPerformed under certain conditions [v4]
Tejpal Rebari
trebari at openjdk.java.net
Sat Dec 12 12:47:56 UTC 2020
On Fri, 11 Dec 2020 10:18:12 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
>> In case of the first attempt to bring down the popup menu the event was consumed by following code of BasicPopupMenuUI
>> boolean consumeEvent =
>> UIManager.getBoolean("PopupMenu.consumeEventOnClose");
>> // Consume the event so that normal processing stops.
>> if(consumeEvent && !(src instanceof MenuElement)) {
>> me.consume();
>> }
>> The PopupMenu.consumeEventOnClose is true for Windows, Motif, Nimbus, and GTK LAF and this issue is seen in all these LookAndFeels.
>> For Metal LAF this variable is never set to true so it uses of BasicLookAndFeel which is set to FALSE
>> This issue is not seen on MetalLAF.
>>
>> So changed PopupMenu.consumeEventOnClose to FALSE for Windows, Motif, Nimbus, and GTK LAF and
>> it fixes the issue.
>
> Any idea why commenting popup.setInvoker(jtb); line in the test works even without the fix?
In case of commenting popup.setInvoker(jtb);
the following line of code in BasicPopupMenuUI is never called
boolean consumeEvent =UIManager.getBoolean("PopupMenu.consumeEventOnClose");
// Consume the event so that normal processing stops.
if(consumeEvent && !(src instanceof MenuElement)) {
me.consume();
}
So the event is not consumed here by me.consume() and the the issue is not seen.
-------------
PR: https://git.openjdk.java.net/jdk/pull/600
More information about the swing-dev
mailing list