RFR: 8268084: [macos] Disabled JMenuItem arrow is not disabled [v5]

Prasanta Sadhukhan psadhukhan at openjdk.java.net
Mon Sep 13 08:53:56 UTC 2021


On Fri, 10 Sep 2021 04:08:49 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> It is called from AquaMenuPainter#405 and 378
>> if (c instanceof JMenu && (model.isArmed() || model.isSelected()) && arrowIcon instanceof InvertableIcon) {
>>             ((InvertableIcon)arrowIcon).getInvertedIcon().paintIcon(c, g, arrowIconRect.x, arrowIconRect.y);
>>         }
>> I could not find at what point arrowIcon or checkIcon would be instance of InvertableIcon...
>> I guess we can take one fix at a time since this normal icon disable issue itself is there from macox port origin 
>> and fix it later if any issue comes for InvertableIcon...
>
>> I could not find at what point arrowIcon or checkIcon would be an instance of InvertableIcon...
> 
> All InvertableImageIcon objects are InvertableIcon since it implements that interface, so that part is always true, and if it possible to make "(c instanceof JMenu && (model.isArmed() || model.isSelected()"== true for the disabled components then "getInvertedIcon" should return disabled icon.

Arrow icon InvertedIcon is handled by testing with setSelected(true) and setEnabled(false)
but
for checkIcon, it checks for

if (item.isArmed() && checkIcon instanceof InvertableIcon) {
            ((InvertableIcon)checkIcon).getInvertedIcon().paintIcon(item, g, checkIconRect.x, checkIconRect.y);
        } 


but even if we do setArmed(true) it is set to false here
https://github.com/openjdk/jdk/blob/master/src/java.desktop/share/classes/javax/swing/JMenuItem.java#L312

if (!b && !UIManager.getBoolean("MenuItem.disabledAreNavigable")) {
            setArmed(false);
        }

and MenuItem.disabledAreNavigable is not defined for Aqua so I guess it's false so InvertedIcon is not called for checkIcon

-------------

PR: https://git.openjdk.java.net/jdk/pull/5310



More information about the client-libs-dev mailing list