altosuilib: Move menu bars into the Mac OS X top bar
authorKeith Packard <keithp@keithp.com>
Tue, 17 Jun 2014 04:58:13 +0000 (21:58 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 17 Jun 2014 04:58:13 +0000 (21:58 -0700)
Setting these properties causes the top menu bar to get placed into
the Mac OS X window system menu bar

Signed-off-by: Keith Packard <keithp@keithp.com>
altosuilib/AltosUIFrame.java

index 6e62c762948d83578814c5b26d4534a0c92ff352..2de1fb1c5afc17b98a38126566cb199bda2d0a22 100644 (file)
@@ -157,11 +157,28 @@ public class AltosUIFrame extends JFrame implements AltosUIListener, AltosPositi
                }
        }
 
+       static boolean global_settings_done;
+
+       public String getName() {
+               return "Altus Metrum";
+       }
+
        void init() {
                AltosUIPreferences.register_ui_listener(this);
                AltosUIPreferences.register_position_listener(this);
                position = AltosUIPreferences.position();
                addWindowListener(new AltosUIFrameListener());
+
+               /* Try to make menus live in the menu bar like regular Mac apps */
+               if (!global_settings_done) {
+                       try {
+                               global_settings_done = true;
+                               System.setProperty("com.apple.mrj.application.apple.menu.about.name", getName());
+                               System.setProperty("com.apple.macos.useScreenMenuBar", "true");
+                               System.setProperty( "apple.laf.useScreenMenuBar", "true" ); // for older versions of Java
+                       } catch (Exception e) {
+                       }
+               }
                set_icon();
        }