new frame positioning
[debian/openrocket] / src / net / sf / openrocket / gui / main / BasicFrame.java
index a9cbbfc0b00fdb3d466d595ba9df66d234997658..cd548056f5ba089dd5a3a8384a44c103493ae233 100644 (file)
@@ -30,6 +30,7 @@ import java.util.List;
 import java.util.concurrent.ExecutionException;
 
 import javax.swing.Action;
+import javax.swing.BorderFactory;
 import javax.swing.InputMap;
 import javax.swing.JButton;
 import javax.swing.JComponent;
@@ -80,7 +81,6 @@ import net.sf.openrocket.gui.dialogs.WarningDialog;
 import net.sf.openrocket.gui.dialogs.optimization.GeneralOptimizationDialog;
 import net.sf.openrocket.gui.dialogs.preferences.PreferencesDialog;
 import net.sf.openrocket.gui.main.componenttree.ComponentTree;
-import net.sf.openrocket.gui.optimization.OptimizationTestDialog;
 import net.sf.openrocket.gui.scalefigure.RocketPanel;
 import net.sf.openrocket.l10n.Translator;
 import net.sf.openrocket.logging.LogHelper;
@@ -125,9 +125,6 @@ public class BasicFrame extends JFrame {
        private static final ArrayList<BasicFrame> frames = new ArrayList<BasicFrame>();
        
 
-
-
-
        /**
         * Whether "New" and "Open" should replace this frame.
         * Should be set to false on the first rocket modification.
@@ -367,8 +364,8 @@ public class BasicFrame extends JFrame {
                scroll.setBorder(null);
                scroll.setViewportBorder(null);
                
-               TitledBorder border = new TitledBorder(trans.get("BasicFrame.title.Addnewcomp"));
-               border.setTitleFont(border.getTitleFont().deriveFont(Font.BOLD));
+               TitledBorder border = BorderFactory.createTitledBorder(trans.get("BasicFrame.title.Addnewcomp"));
+               GUIUtil.changeFontStyle(border, Font.BOLD);
                scroll.setBorder(border);
                
                panel.add(scroll, "grow");
@@ -648,6 +645,19 @@ public class BasicFrame extends JFrame {
                menu.add(item);
                
 
+               item = new JMenuItem(trans.get("main.menu.analyze.optimization"), KeyEvent.VK_O);
+               item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.analyze.optimization.desc"));
+               item.addActionListener(new ActionListener() {
+                       @Override
+                       public void actionPerformed(ActionEvent e) {
+                               log.user("Rocket optimization selected");
+                               new GeneralOptimizationDialog(document, BasicFrame.this).setVisible(true);
+                       }
+               });
+               menu.add(item);
+               
+
+
                ////  Debug
                // (shown if openrocket.debug.menu is defined)
                if (System.getProperty("openrocket.debug.menu") != null) {
@@ -951,25 +961,6 @@ public class BasicFrame extends JFrame {
                menu.add(item);
                
 
-               item = new JMenuItem("General optimization test");
-               item.addActionListener(new ActionListener() {
-                       @Override
-                       public void actionPerformed(ActionEvent e) {
-                               new GeneralOptimizationDialog(document, BasicFrame.this).setVisible(true);
-                       }
-               });
-               menu.add(item);
-               
-
-               item = new JMenuItem("Optimization test");
-               item.addActionListener(new ActionListener() {
-                       @Override
-                       public void actionPerformed(ActionEvent e) {
-                               new OptimizationTestDialog(BasicFrame.this, document).setVisible(true);
-                       }
-               });
-               menu.add(item);
-               
                return menu;
        }
        
@@ -1013,6 +1004,10 @@ public class BasicFrame extends JFrame {
                                
                                // Close previous window if replacing
                                if (replaceable && document.isSaved()) {
+                                       // We are replacing the frame, make new window have current location
+                                       BasicFrame newFrame = frames.get(frames.size() - 1);
+                                       newFrame.setLocation(this.getLocation());
+                                       
                                        log.info("Closing window because it is replaceable");
                                        closeAction();
                                        replaceable = false;
@@ -1194,6 +1189,7 @@ public class BasicFrame extends JFrame {
                doc.setFile(file);
                doc.setSaved(true);
                
+
                // Open the frame
                log.debug("Opening new frame with the document");
                BasicFrame frame = new BasicFrame(doc);
@@ -1370,13 +1366,6 @@ public class BasicFrame extends JFrame {
         * 
         */
        public void printAction() {
-               if (!Prefs.getBoolean("printing.experimental.communicated", false)) {
-                       log.info("Showing printing is experimental warning to the user");
-                       JOptionPane.showMessageDialog(this, "Printing is an currently an experimental feature " +
-                                       "and might not fully work on all platforms",
-                                       "Experimental feature", JOptionPane.WARNING_MESSAGE);
-                       Prefs.putBoolean("printing.experimental.communicated", true);
-               }
                new PrintDialog(this, document).setVisible(true);
        }