src/share/classes/java/awt/Window.java

Print this page




1076             Window child = w.ownedWindowList.elementAt(i).get();
1077             if (child != null) {
1078                 updateChildFocusableWindowState(child);
1079             }
1080         }
1081     }
1082 
1083     synchronized void postWindowEvent(int id) {
1084         if (windowListener != null
1085             || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0
1086             ||  Toolkit.enabledOnToolkit(AWTEvent.WINDOW_EVENT_MASK)) {
1087             WindowEvent e = new WindowEvent(this, id);
1088             Toolkit.getEventQueue().postEvent(e);
1089         }
1090     }
1091 
1092     /**
1093      * Hide this Window, its subcomponents, and all of its owned children.
1094      * The Window and its subcomponents can be made visible again
1095      * with a call to {@code show}.
1096      * </p>
1097      * @see #show
1098      * @see #dispose
1099      * @deprecated As of JDK version 1.5, replaced by
1100      * {@link #setVisible(boolean)}.
1101      */
1102     @Deprecated
1103     public void hide() {
1104         synchronized(ownedWindowList) {
1105             for (int i = 0; i < ownedWindowList.size(); i++) {
1106                 Window child = ownedWindowList.elementAt(i).get();
1107                 if ((child != null) && child.visible) {
1108                     child.hide();
1109                     child.showWithParent = true;
1110                 }
1111             }
1112         }
1113         if (isModalBlocked()) {
1114             modalBlocker.unblockWindow(this);
1115         }
1116         super.hide();


3374 
3375 
3376     /**
3377      * Sets whether this Window should appear at the default location for the
3378      * native windowing system or at the current location (returned by
3379      * {@code getLocation}) the next time the Window is made visible.
3380      * This behavior resembles a native window shown without programmatically
3381      * setting its location.  Most windowing systems cascade windows if their
3382      * locations are not explicitly set. The actual location is determined once the
3383      * window is shown on the screen.
3384      * <p>
3385      * This behavior can also be enabled by setting the System Property
3386      * "java.awt.Window.locationByPlatform" to "true", though calls to this method
3387      * take precedence.
3388      * <p>
3389      * Calls to {@code setVisible}, {@code setLocation} and
3390      * {@code setBounds} after calling {@code setLocationByPlatform} clear
3391      * this property of the Window.
3392      * <p>
3393      * For example, after the following code is executed:
3394      * <pre><blockquote>
3395      * setLocationByPlatform(true);
3396      * setVisible(true);
3397      * boolean flag = isLocationByPlatform();
3398      * </blockquote></pre>
3399      * The window will be shown at platform's default location and
3400      * {@code flag} will be {@code false}.
3401      * <p>
3402      * In the following sample:
3403      * <pre><blockquote>
3404      * setLocationByPlatform(true);
3405      * setLocation(10, 10);
3406      * boolean flag = isLocationByPlatform();
3407      * setVisible(true);
3408      * </blockquote></pre>
3409      * The window will be shown at (10, 10) and {@code flag} will be
3410      * {@code false}.
3411      *
3412      * @param locationByPlatform {@code true} if this Window should appear
3413      *        at the default location, {@code false} if at the current location
3414      * @throws {@code IllegalComponentStateException} if the window
3415      *         is showing on screen and locationByPlatform is {@code true}.
3416      * @see #setLocation
3417      * @see #isShowing
3418      * @see #setVisible
3419      * @see #isLocationByPlatform
3420      * @see java.lang.System#getProperty(String)
3421      * @since 1.5
3422      */
3423     public void setLocationByPlatform(boolean locationByPlatform) {
3424         synchronized (getTreeLock()) {
3425             if (locationByPlatform && isShowing()) {
3426                 throw new IllegalComponentStateException("The window is showing on screen.");
3427             }
3428             this.locationByPlatform = locationByPlatform;
3429         }
3430     }
3431 
3432     /**
3433      * Returns {@code true} if this Window will appear at the default location
3434      * for the native windowing system the next time this Window is made visible.




1076             Window child = w.ownedWindowList.elementAt(i).get();
1077             if (child != null) {
1078                 updateChildFocusableWindowState(child);
1079             }
1080         }
1081     }
1082 
1083     synchronized void postWindowEvent(int id) {
1084         if (windowListener != null
1085             || (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0
1086             ||  Toolkit.enabledOnToolkit(AWTEvent.WINDOW_EVENT_MASK)) {
1087             WindowEvent e = new WindowEvent(this, id);
1088             Toolkit.getEventQueue().postEvent(e);
1089         }
1090     }
1091 
1092     /**
1093      * Hide this Window, its subcomponents, and all of its owned children.
1094      * The Window and its subcomponents can be made visible again
1095      * with a call to {@code show}.

1096      * @see #show
1097      * @see #dispose
1098      * @deprecated As of JDK version 1.5, replaced by
1099      * {@link #setVisible(boolean)}.
1100      */
1101     @Deprecated
1102     public void hide() {
1103         synchronized(ownedWindowList) {
1104             for (int i = 0; i < ownedWindowList.size(); i++) {
1105                 Window child = ownedWindowList.elementAt(i).get();
1106                 if ((child != null) && child.visible) {
1107                     child.hide();
1108                     child.showWithParent = true;
1109                 }
1110             }
1111         }
1112         if (isModalBlocked()) {
1113             modalBlocker.unblockWindow(this);
1114         }
1115         super.hide();


3373 
3374 
3375     /**
3376      * Sets whether this Window should appear at the default location for the
3377      * native windowing system or at the current location (returned by
3378      * {@code getLocation}) the next time the Window is made visible.
3379      * This behavior resembles a native window shown without programmatically
3380      * setting its location.  Most windowing systems cascade windows if their
3381      * locations are not explicitly set. The actual location is determined once the
3382      * window is shown on the screen.
3383      * <p>
3384      * This behavior can also be enabled by setting the System Property
3385      * "java.awt.Window.locationByPlatform" to "true", though calls to this method
3386      * take precedence.
3387      * <p>
3388      * Calls to {@code setVisible}, {@code setLocation} and
3389      * {@code setBounds} after calling {@code setLocationByPlatform} clear
3390      * this property of the Window.
3391      * <p>
3392      * For example, after the following code is executed:
3393      * <pre>
3394      * setLocationByPlatform(true);
3395      * setVisible(true);
3396      * boolean flag = isLocationByPlatform();
3397      * </pre>
3398      * The window will be shown at platform's default location and
3399      * {@code flag} will be {@code false}.
3400      * <p>
3401      * In the following sample:
3402      * <pre>
3403      * setLocationByPlatform(true);
3404      * setLocation(10, 10);
3405      * boolean flag = isLocationByPlatform();
3406      * setVisible(true);
3407      * </pre>
3408      * The window will be shown at (10, 10) and {@code flag} will be
3409      * {@code false}.
3410      *
3411      * @param locationByPlatform {@code true} if this Window should appear
3412      *        at the default location, {@code false} if at the current location
3413      * @throws IllegalComponentStateException if the window
3414      *         is showing on screen and locationByPlatform is {@code true}.
3415      * @see #setLocation
3416      * @see #isShowing
3417      * @see #setVisible
3418      * @see #isLocationByPlatform
3419      * @see java.lang.System#getProperty(String)
3420      * @since 1.5
3421      */
3422     public void setLocationByPlatform(boolean locationByPlatform) {
3423         synchronized (getTreeLock()) {
3424             if (locationByPlatform && isShowing()) {
3425                 throw new IllegalComponentStateException("The window is showing on screen.");
3426             }
3427             this.locationByPlatform = locationByPlatform;
3428         }
3429     }
3430 
3431     /**
3432      * Returns {@code true} if this Window will appear at the default location
3433      * for the native windowing system the next time this Window is made visible.