Ticket #1606: PreferencesAction.diff

File PreferencesAction.diff, 1.5 KB (added by Henry Loenwind, 17 years ago)
  • src/org/openstreetmap/josm/actions/PreferencesAction.java

     
    4143                JDialog dlg = pane.createDialog(Main.parent, tr("Preferences"));
    4244                dlg.setResizable(true);
    4345
    44                 if (dlg.getWidth() > 600)
    45                         dlg.setSize(600, dlg.getHeight());
    46                 if (dlg.getHeight() > 600)
    47                         dlg.setSize(dlg.getWidth(),600);
     46//              if (dlg.getWidth() > 600)
     47//                      dlg.setSize(600, dlg.getHeight());
     48//              if (dlg.getHeight() > 600)
     49//                      dlg.setSize(dlg.getWidth(),600);
    4850
     51                int JOSMWidth = Main.parent.getWidth();
     52                int JOSMHeight = Main.parent.getHeight();
     53
     54                if (JOSMWidth > 2000 && JOSMWidth >  JOSMHeight * 2)
     55                        // don't center on horizontal span monitor configurations (yes, can be selfish sometimes)
     56                        JOSMWidth /= 2;
     57
     58                int targetWidth = JOSMWidth / 2;
     59                if (targetWidth < 600) targetWidth = 600;
     60                if (targetWidth > 1200) targetWidth = 1200;
     61                int targetHeight = (JOSMHeight * 3) / 4;
     62                if (targetHeight < 600) targetHeight = 600;
     63                if (targetHeight > 1200) targetHeight = 1200;
     64
     65                int targetX = Main.parent.getX() + JOSMWidth / 2 - targetWidth / 2;
     66                int targetY = Main.parent.getY() + JOSMHeight / 2 - targetHeight / 2;
     67
     68                dlg.setBounds(targetX, targetY, targetWidth, targetHeight);
     69
    4970                dlg.setVisible(true);
    5071                if (pane.getValue() instanceof Integer && (Integer)pane.getValue() == JOptionPane.OK_OPTION)
    5172                        prefDlg.ok();