Ignore:
Timestamp:
2009-12-28T00:15:22+01:00 (14 years ago)
Author:
Gubaer
Message:

Partial commit due to issue described in #4137
Breaks the build

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java

    r2512 r2688  
    66import java.awt.Component;
    77import java.awt.Dimension;
    8 import java.awt.Frame;
    98import java.awt.Point;
    109import java.awt.Toolkit;
     
    1211import java.util.regex.Matcher;
    1312import java.util.regex.Pattern;
    14 
    15 import javax.swing.JOptionPane;
    1613
    1714import org.openstreetmap.josm.Main;
     
    4037
    4138    /**
    42      * Replies a window geometry object for a window which a specific size which is centered
    43      * relative to a parent window
    44      *
    45      * @param parent the parent window
     39     * Replies a window geometry object for a window with a specific size which is centered
     40     * relative to the parent window of a reference component.
     41     *
     42     * @param reference the reference component.
    4643     * @param extent the size
    4744     * @return the geometry object
    4845     */
    49     static public WindowGeometry centerInWindow(Component parent, Dimension extent) {
    50         Frame parentWindow = JOptionPane.getFrameForComponent(parent);
     46    static public WindowGeometry centerInWindow(Component reference, Dimension extent) {
     47        Window parentWindow = null;
     48        while(reference != null && ! (reference instanceof Window) ) {
     49            reference = reference.getParent();
     50        }
     51        if (reference == null || ! (reference instanceof Window))
     52            return new WindowGeometry(new Point(0,0), extent);
     53        parentWindow = (Window)reference;
    5154        Point topLeft = new Point(
    5255                Math.max(0, (parentWindow.getSize().width - extent.width) /2),
     
    156159            initFromPreferences(preferenceKey);
    157160        } catch(WindowGeometryException e) {
    158 //            System.out.println(tr("Warning: Failed to restore window geometry from key ''{0}''. Falling back to default geometry. Details: {1}", preferenceKey, e.getMessage()));
     161            //            System.out.println(tr("Warning: Failed to restore window geometry from key ''{0}''. Falling back to default geometry. Details: {1}", preferenceKey, e.getMessage()));
    159162            initFromWindowGeometry(defaultGeometry);
    160163        }
Note: See TracChangeset for help on using the changeset viewer.