Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8365625

Can't change accelerator colors in Windows L&F

XMLWordPrintable

    • b11
    • 26
    • windows

      After JDK-8348760, the accelerator colors are cached in static fields of WindowsMenuItemUI [1][2]. If these colors are customised in UIManager, the colors aren't updated after any of them is set to a non-UIResource value.

      To reproduce the problem, run the attached jtreg test MenuItemAcceleratorColor.java. (Put it into test/jdk/com/sun/java/swing/plaf/windows/MenuItem.)

      In Windows Look and Feel, all the accelerators are green and red when selected. Before JDK-8348760, the first and the last menu items use the default accelerator color which matches the menu text color; the second item renders its accelerator in green and red, and the third one uses magenta and yellow.

      Windows Classic Look and Feel isn't affected, it renders correctly because rendering is handled by the super class, namely BasicMenuItemUI.

      [1] https://github.com/openjdk/jdk/blob/b69a3849b21b4bb1e21ad276633de45da6200168/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java#L137-L156
      [2] https://github.com/openjdk/jdk/blob/b69a3849b21b4bb1e21ad276633de45da6200168/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsMenuItemUI.java#L70-L72

        1. MenuItemAcceleratorColor.java
          6 kB
          Alexey Ivanov
        2. jdk-26-ea+10-1035.png
          13 kB
          Alexey Ivanov
        3. jdk-26-ea+12-1187.png
          13 kB
          Alexey Ivanov

            psadhukhan Prasanta Sadhukhan
            aivanov Alexey Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: