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

Sergey Bylokhov serb at openjdk.java.net
Wed Sep 8 21:04:06 UTC 2021


On Sat, 4 Sep 2021 11:09:19 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> It is seen in macos disabled JMenuItem arrow is not disabled even though JMenuItem itself is disabled.
>> In native app, same menuitem arrow is disabled for disabled menuitem.
>> 
>> Issue is when AquaMenuPainter#paintMenuItem() is called, it tries to draw a ImageIcon image of the arrow via ImageIcon#paintIcon which tries to generate MultiResolutionCachedImage via getResolutionVariant() by calling AquaUtils#generateFilteredImage.
>> It does not take into account if disabled arrow icon image needs to be drawn or not, so it is always enabled.
>> 
>> Proposed fix is to generate a disabled ImageIcon image of the same arrow icon and use it for disabled state.
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Add menuitem checkicon test

src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java line 235:

> 233:     static class InvertableImageIcon extends ImageIcon implements InvertableIcon, UIResource {
> 234:         Icon invertedImage;
> 235:         Icon disabledIcon;

could be private

src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java line 244:

> 242:             if (!c.isEnabled()) {
> 243:                 if (disabledIcon == null) {
> 244:                     disabledIcon = new ImageIconUIResource(GrayFilter.

It is not necessary to use ImageIconUIResource since we never return this image but only draw it.

src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java line 254:

> 252: 
> 253:         @Override
> 254:         public Icon getInvertedIcon() {

When we draw result of this method? Is it possible that we use the getInvertedIcon for disabled menus as well?

test/jdk/javax/swing/plaf/aqua/JMenuItemDisableArrowButtonTest.java line 27:

> 25:  * @requires (os.family == "mac")
> 26:  * @bug 8268084
> 27:  * @summary  Verifies disabled JMenuItem arrow is disabled

arrow and check

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

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



More information about the client-libs-dev mailing list