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

macOS - System App Shortcuts no longer work

XMLWordPrintable

    • x86_64
    • os_x

      ADDITIONAL SYSTEM INFORMATION :
      macOS 15.3.2 (24D81)

      openjdk version "21.0.8" 2025-07-15 LTS
      OpenJDK Runtime Environment Temurin-21.0.8+9 (build 21.0.8+9-LTS)
      OpenJDK 64-Bit Server VM Temurin-21.0.8+9 (build 21.0.8+9-LTS, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      On macOS, App Shortcuts that are defined in the OS no longer work as expected.
      - The custom shortcut no longer works.

      p.s. The custom shortcut is still working when the menu is open while the shortcut is used. The custom shortcut is shown in the menu item correctly.



      REGRESSION : Last worked in version 8u461

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Register an "App Shortcut" in macOS
      - Open System Settings...
      - Go to Keyboard
      - Open "Keyboard Shortcuts..."
      - Go to "App Shortcuts"

      Add a shortcut for All Applications
      - Click the + icon
      - Fill in the menu title: "My Menu Item" (needs to be exact and without the quotes)
      - use Shift-Command-R as Keyboard Shortcut

      Run the test application
      - Open the java test application
      - use the shortcut Shift-Command-R

      Look at the console logging.
      If the menu item is executed successfully, it will print "My Menu Item is executed" in the console

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The menu item gets triggered and "My Menu Item is executed" is printed in the console
      ACTUAL -
      nothing happens

      ---------- BEGIN SOURCE ----------
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.lang.reflect.InvocationTargetException;

      import javax.swing.JFrame;
      import javax.swing.JMenu;
      import javax.swing.JMenuBar;
      import javax.swing.JMenuItem;
      import javax.swing.SwingUtilities;
      import javax.swing.UIManager;
      import javax.swing.UnsupportedLookAndFeelException;

      public class App {
      public static void main(String[] args) {
      String lookAndFeel = UIManager.getSystemLookAndFeelClassName();
      try {
      UIManager.setLookAndFeel(lookAndFeel);
      } catch (ClassNotFoundException e) {
      e.printStackTrace();
      } catch (InstantiationException e) {
      e.printStackTrace();
      } catch (IllegalAccessException e) {
      e.printStackTrace();
      } catch (UnsupportedLookAndFeelException e) {
      e.printStackTrace();
      }

      System.setProperty("apple.laf.useScreenMenuBar", "true");

      try {
      SwingUtilities.invokeAndWait(new Runnable() {
      @Override
      public void run() {
      JFrame frame = new JFrame("App");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(400, 300);
      frame.setLocationRelativeTo(null);

      JMenuItem newFolder = new JMenuItem("My Menu Item");
      newFolder.addActionListener(new FolderHandler());

      JMenu fileMenu = new JMenu("File");
      fileMenu.add(newFolder);

      JMenuBar menuBar = new JMenuBar();
      menuBar.add(fileMenu);
      frame.setJMenuBar(menuBar);

      frame.setVisible(true);
      }
      });
      } catch (InvocationTargetException e) {
      e.printStackTrace();
      } catch (InterruptedException e) {
      e.printStackTrace();
      }
      }

      private static class FolderHandler implements ActionListener {
      @Override
      public void actionPerformed(ActionEvent e) {
      System.out.println("My Menu Item is executed");
      }
      }
      }

      ---------- END SOURCE ----------

        1. App.java
          2 kB
          Patricia Tavares

            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: