@@ -386,7 +386,7 @@ public void setTrayIconWindow(boolean isTrayIconWindow) {
386386//
387387// private static final Logger log = Logger.getLogger("java.awt.Window");
388388
389- // private static final boolean locationByPlatformProp;
389+ private static final boolean locationByPlatformProp = false ;
390390
391391 transient boolean isTrayIconWindow = false ;
392392
@@ -536,7 +536,8 @@ public Window(Window owner) {
536536 public Window (Window owner , GraphicsConfiguration gc ) {
537537 super ();
538538 秘winOrApplet = true ;
539- 秘paintClass = 秘updateClass = /**@j2sNative C$ || */ null ;
539+ 秘paintClass = 秘updateClass = /** @j2sNative C$ || */
540+ null ;
540541 setAppContext ();
541542 parent = owner ;
542543 if (owner != null )
@@ -567,16 +568,15 @@ public Window(Window owner, GraphicsConfiguration gc) {
567568
568569 /* offset the initial location with the original of the screen */
569570 /* and any insets */
570- // SwingJS TODO ??
571- // Rectangle screenBounds = graphicsConfig.getBounds();
572- // Insets screenInsets = getToolkit().getScreenInsets(graphicsConfig);
573- // int x = getX() + screenBounds.x + screenInsets.left;
574- // int y = getY() + screenBounds.y + screenInsets.top;
575- // if (x != this.x || y != this.y) {
576- // setLocation(x, y);
577- // /* reset after setLocation */
578- // // setLocationByPlatform(locationByPlatformProp);
579- // }
571+ Rectangle screenBounds = getGraphicsConfiguration ().getBounds ();
572+ Insets screenInsets = getToolkit ().getScreenInsets (graphicsConfig );
573+ int x = getX () + screenBounds .x + screenInsets .left ;
574+ int y = getY () + screenBounds .y + screenInsets .top ;
575+ if (x != ((Container ) this ).x || y != ((Container ) this ).y ) {
576+ setLocation (x , y );
577+ /* reset after setLocation */
578+ setLocationByPlatform (locationByPlatformProp );
579+ }
580580
581581 modalExclusionType = ModalExclusionType .NO_EXCLUDE ;
582582
@@ -3159,80 +3159,80 @@ protected boolean canContainFocusOwner(Component focusOwnerCandidate) {
31593159 return super .canContainFocusOwner (focusOwnerCandidate ) && isFocusableWindow ();
31603160 }
31613161
3162- // private boolean locationByPlatform = locationByPlatformProp;
3163-
3164- // /**
3165- // * Sets whether this Window should appear at the default location for the
3166- // * native windowing system or at the current location (returned by
3167- // * <code>getLocation</code>) the next time the Window is made visible.
3168- // * This behavior resembles a native window shown without programmatically
3169- // * setting its location. Most windowing systems cascade windows if their
3170- // * locations are not explicitly set. The actual location is determined once the
3171- // * window is shown on the screen.
3172- // * <p>
3173- // * This behavior can also be enabled by setting the System Property
3174- // * "java.awt.Window.locationByPlatform" to "true", though calls to this method
3175- // * take precedence.
3176- // * <p>
3177- // * Calls to <code>setVisible</code>, <code>setLocation</code> and
3178- // * <code>setBounds</code> after calling <code>setLocationByPlatform</code> clear
3179- // * this property of the Window.
3180- // * <p>
3181- // * For example, after the following code is executed:
3182- // * <pre><blockquote>
3183- // * setLocationByPlatform(true);
3184- // * setVisible(true);
3185- // * boolean flag = isLocationByPlatform();
3186- // * </blockquote></pre>
3187- // * The window will be shown at platform's default location and
3188- // * <code>flag</code> will be <code>false</code>.
3189- // * <p>
3190- // * In the following sample:
3191- // * <pre><blockquote>
3192- // * setLocationByPlatform(true);
3193- // * setLocation(10, 10);
3194- // * boolean flag = isLocationByPlatform();
3195- // * setVisible(true);
3196- // * </blockquote></pre>
3197- // * The window will be shown at (10, 10) and <code>flag</code> will be
3198- // * <code>false</code>.
3199- // *
3200- // * @param locationByPlatform <code>true</code> if this Window should appear
3201- // * at the default location, <code>false</code> if at the current location
3202- // * @throws <code>IllegalComponentStateException</code> if the window
3203- // * is showing on screen and locationByPlatform is <code>true</code>.
3204- // * @see #setLocation
3205- // * @see #isShowing
3206- // * @see #setVisible
3207- // * @see #isLocationByPlatform
3208- // * @see java.lang.System#getProperty(String)
3209- // * @since 1.5
3210- // */
3211- // public void setLocationByPlatform(boolean locationByPlatform) {
3162+ private boolean locationByPlatform = locationByPlatformProp ;
3163+
3164+ /**
3165+ * Sets whether this Window should appear at the default location for the
3166+ * native windowing system or at the current location (returned by
3167+ * <code>getLocation</code>) the next time the Window is made visible.
3168+ * This behavior resembles a native window shown without programmatically
3169+ * setting its location. Most windowing systems cascade windows if their
3170+ * locations are not explicitly set. The actual location is determined once the
3171+ * window is shown on the screen.
3172+ * <p>
3173+ * This behavior can also be enabled by setting the System Property
3174+ * "java.awt.Window.locationByPlatform" to "true", though calls to this method
3175+ * take precedence.
3176+ * <p>
3177+ * Calls to <code>setVisible</code>, <code>setLocation</code> and
3178+ * <code>setBounds</code> after calling <code>setLocationByPlatform</code> clear
3179+ * this property of the Window.
3180+ * <p>
3181+ * For example, after the following code is executed:
3182+ * <pre><blockquote>
3183+ * setLocationByPlatform(true);
3184+ * setVisible(true);
3185+ * boolean flag = isLocationByPlatform();
3186+ * </blockquote></pre>
3187+ * The window will be shown at platform's default location and
3188+ * <code>flag</code> will be <code>false</code>.
3189+ * <p>
3190+ * In the following sample:
3191+ * <pre><blockquote>
3192+ * setLocationByPlatform(true);
3193+ * setLocation(10, 10);
3194+ * boolean flag = isLocationByPlatform();
3195+ * setVisible(true);
3196+ * </blockquote></pre>
3197+ * The window will be shown at (10, 10) and <code>flag</code> will be
3198+ * <code>false</code>.
3199+ *
3200+ * @param locationByPlatform <code>true</code> if this Window should appear
3201+ * at the default location, <code>false</code> if at the current location
3202+ * @throws <code>IllegalComponentStateException</code> if the window
3203+ * is showing on screen and locationByPlatform is <code>true</code>.
3204+ * @see #setLocation
3205+ * @see #isShowing
3206+ * @see #setVisible
3207+ * @see #isLocationByPlatform
3208+ * @see java.lang.System#getProperty(String)
3209+ * @since 1.5
3210+ */
3211+ public void setLocationByPlatform (boolean locationByPlatform ) {
3212+ synchronized (getTreeLock ()) {
3213+ if (locationByPlatform && isShowing ()) {
3214+ throw new IllegalComponentStateException ("The window is showing on screen." );
3215+ }
3216+ this .locationByPlatform = locationByPlatform ;
3217+ }
3218+ }
3219+
3220+ /**
3221+ * Returns <code>true</code> if this Window will appear at the default location
3222+ * for the native windowing system the next time this Window is made visible.
3223+ * This method always returns <code>false</code> if the Window is showing on the
3224+ * screen.
3225+ *
3226+ * @return whether this Window will appear at the default location
3227+ * @see #setLocationByPlatform
3228+ * @see #isShowing
3229+ * @since 1.5
3230+ */
3231+ public boolean isLocationByPlatform () {
32123232// synchronized (getTreeLock()) {
3213- // if (locationByPlatform && isShowing()) {
3214- // throw new IllegalComponentStateException("The window is showing on screen.");
3215- // }
3216- // this.locationByPlatform = locationByPlatform;
3217- // }
3218- // }
3219-
3220- // /**
3221- // * Returns <code>true</code> if this Window will appear at the default location
3222- // * for the native windowing system the next time this Window is made visible.
3223- // * This method always returns <code>false</code> if the Window is showing on the
3224- // * screen.
3225- // *
3226- // * @return whether this Window will appear at the default location
3227- // * @see #setLocationByPlatform
3228- // * @see #isShowing
3229- // * @since 1.5
3230- // */
3231- // public boolean isLocationByPlatform() {
3232- // synchronized (getTreeLock()) {
3233- // return locationByPlatform;
3234- // }
3235- // }
3233+ return locationByPlatform ;
3234+ // }
3235+ }
32363236
32373237 /**
32383238 * {@inheritDoc}
0 commit comments