altosuilib: Move menu bars into the Mac OS X top bar
[fw/altos] / altosuilib / AltosUIFrame.java
index 3dc2a0ad3f43e8d8110e0605b89d825589e227ad..2de1fb1c5afc17b98a38126566cb199bda2d0a22 100644 (file)
@@ -15,7 +15,7 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-package org.altusmetrum.altosuilib_1;
+package org.altusmetrum.altosuilib_2;
 
 import java.awt.*;
 import java.awt.event.*;
@@ -73,6 +73,9 @@ public class AltosUIFrame extends JFrame implements AltosUIListener, AltosPositi
                super.setLocationByPlatform(lbp);
        }
 
+       public void scan_device_selected(AltosDevice device) {
+       }
+
        public void setSize() {
                /* Smash sizes around so that the window comes up in the right shape */
                Insets i = getInsets();
@@ -154,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();
        }