Changeset 4248 in josm for trunk/src/org


Ignore:
Timestamp:
2011-07-15T19:07:53+02:00 (13 years ago)
Author:
xeen
Message:

fix #6556

When the prefs are opened for the very first time, the window is now at most
as large as the parent window. After that, the dimensions are stored in JOSM's
preferences, so it won't work for existing installations.

As an additional measure, the dialog cannot be larger than the screen dimension
and as far as my testing goes this setting overwrites the stored dimension.
Unfortunately there is no way to determine the space occupied by application
launchers/taskbars across all systems and the pref dialog may be hidden behind
them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java

    r3855 r4248  
    99import java.awt.Dimension;
    1010import java.awt.FlowLayout;
     11import java.awt.Insets;
     12import java.awt.Toolkit;
    1113import java.awt.event.ActionEvent;
    1214import java.awt.event.KeyEvent;
     
    6163        super(JOptionPane.getFrameForComponent(parent), tr("Preferences"), ModalityType.DOCUMENT_MODAL);
    6264        build();
     65        this.setMinimumSize(new Dimension(600, 350));
     66        // set the maximum width to the current screen. If the dialog is opened on a
     67        // smaller screen than before, this will reset the stored preference.
     68        this.setMaximumSize( Toolkit.getDefaultToolkit().getScreenSize());
    6369    }
    6470
     
    7480    public void setVisible(boolean visible) {
    7581        if (visible) {
     82            // Make the pref window at most as large as the parent JOSM window
     83            // Have to take window decorations into account or the windows will
     84            // be too large
     85            Insets i = this.getParent().getInsets();
     86            Dimension p = this.getParent().getSize();
     87            p = new Dimension(Math.min(p.width-i.left-i.right, 700),
     88                    Math.min(p.height-i.top-i.bottom, 800));
    7689            new WindowGeometry(
    7790                    getClass().getName() + ".geometry",
    7891                    WindowGeometry.centerInWindow(
    7992                            getParent(),
    80                             new Dimension(700,800)
     93                            p
    8194                    )
    8295            ).applySafe(this);
Note: See TracChangeset for help on using the changeset viewer.