altosui/micropeak: Let native window system place windows
authorKeith Packard <keithp@keithp.com>
Sun, 20 Jan 2013 02:04:08 +0000 (18:04 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 20 Jan 2013 23:45:16 +0000 (15:45 -0800)
Instead of forcing windows to our choice of positions, let the host
window pick reasonable locations. This avoids having all of our
windows appear on top of one another.

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

index 70142a93b5d3beeb6d7e0a8c75b8308e31800273..d630ceec763613a38e4fd5abe4c907d9ed9bc0c8 100644 (file)
@@ -552,7 +552,6 @@ public class AltosUI extends AltosUIFrame {
                /* Handle batch-mode */
                if (args.length == 0) {
                        AltosUI altosui = new AltosUI();
-                       altosui.setVisible(true);
 
                        java.util.List<AltosDevice> devices = AltosUSBDevice.list(Altos.product_basestation);
                        for (AltosDevice device : devices)
index 409aea2e98dea105fe6c2abeec3c8cf673ac3def..8a1ba2051d0ccf51a496737efa7f34b0b4697b29 100644 (file)
@@ -66,7 +66,19 @@ public class AltosUIFrame extends JFrame implements AltosUIListener {
                setIconImages(icons);
        }
                        
+       private boolean location_by_platform = true;
 
+       public void setLocationByPlatform(boolean lbp) {
+               location_by_platform = lbp;
+               super.setLocationByPlatform(lbp);
+       }
+               
+       public void setVisible (boolean visible) {
+               if (visible)
+                       setLocationByPlatform(location_by_platform);
+               super.setVisible(visible);
+       }
+               
        public AltosUIFrame() {
                AltosUIPreferences.register_ui_listener(this);
                addWindowListener(new AltosUIFrameListener());
index 5d128dfd9cfaad218bc00362d53868e9b67e2bd1..6f5e432c6b97f5db19e2aa575752eb27d9e12bcd 100644 (file)
@@ -255,7 +255,6 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene
                ps.height += i.top + i.bottom;
 //             setPreferredSize(ps);
                setSize(ps);
-               setLocationByPlatform(true);
                setVisible(true);
        }