330 */
331 private volatile boolean autoRequestFocus = true;
332
333 /*
334 * Indicates that this window is being shown. This flag is set to true at
335 * the beginning of show() and to false at the end of show().
336 *
337 * @see #show()
338 * @see Dialog#shouldBlock
339 */
340 transient boolean isInShow = false;
341
342 /**
343 * The opacity level of the window
344 *
345 * @serial
346 * @see #setOpacity(float)
347 * @see #getOpacity()
348 * @since 1.7
349 */
350 private float opacity = 1.0f;
351
352 /**
353 * The shape assigned to this window. This field is set to {@code null} if
354 * no shape is set (rectangular window).
355 *
356 * @serial
357 * @see #getShape()
358 * @see #setShape(Shape)
359 * @since 1.7
360 */
361 private Shape shape = null;
362
363 private static final String base = "win";
364 private static int nameCounter = 0;
365
366 /*
367 * JDK 1.1 serialVersionUID
368 */
369 private static final long serialVersionUID = 4497834738069338734L;
370
1023 * @see Component#isDisplayable
1024 * @see #toFront
1025 * @deprecated As of JDK version 1.5, replaced by
1026 * {@link #setVisible(boolean)}.
1027 */
1028 @Deprecated
1029 public void show() {
1030 if (peer == null) {
1031 addNotify();
1032 }
1033 validateUnconditionally();
1034
1035 isInShow = true;
1036 if (visible) {
1037 toFront();
1038 } else {
1039 beforeFirstShow = false;
1040 closeSplashScreen();
1041 Dialog.checkShouldBeBlocked(this);
1042 super.show();
1043 synchronized (getTreeLock()) {
1044 this.locationByPlatform = false;
1045 }
1046 for (int i = 0; i < ownedWindowList.size(); i++) {
1047 Window child = ownedWindowList.elementAt(i).get();
1048 if ((child != null) && child.showWithParent) {
1049 child.show();
1050 child.showWithParent = false;
1051 } // endif
1052 } // endfor
1053 if (!isModalBlocked()) {
1054 updateChildrenBlocking();
1055 } else {
1056 // fix for 6532736: after this window is shown, its blocker
1057 // should be raised to front
1058 modalBlocker.toFront_NoClientCode();
1059 }
1060 if (this instanceof Frame || this instanceof Dialog) {
1061 updateChildFocusableWindowState(this);
1062 }
1063 }
1064 isInShow = false;
1065
1098 * @see #show
1099 * @see #dispose
1100 * @deprecated As of JDK version 1.5, replaced by
1101 * {@link #setVisible(boolean)}.
1102 */
1103 @Deprecated
1104 public void hide() {
1105 synchronized(ownedWindowList) {
1106 for (int i = 0; i < ownedWindowList.size(); i++) {
1107 Window child = ownedWindowList.elementAt(i).get();
1108 if ((child != null) && child.visible) {
1109 child.hide();
1110 child.showWithParent = true;
1111 }
1112 }
1113 }
1114 if (isModalBlocked()) {
1115 modalBlocker.unblockWindow(this);
1116 }
1117 super.hide();
1118 synchronized (getTreeLock()) {
1119 this.locationByPlatform = false;
1120 }
1121 }
1122
1123 final void clearMostRecentFocusOwnerOnHide() {
1124 /* do nothing */
1125 }
1126
1127 /**
1128 * Releases all of the native screen resources used by this
1129 * {@code Window}, its subcomponents, and all of its owned
1130 * children. That is, the resources for these {@code Component}s
1131 * will be destroyed, any memory they consume will be returned to the
1132 * OS, and they will be marked as undisplayable.
1133 * <p>
1134 * The {@code Window} and its subcomponents can be made displayable
1135 * again by rebuilding the native resources with a subsequent call to
1136 * {@code pack} or {@code show}. The states of the recreated
1137 * {@code Window} and its subcomponents will be identical to the
1138 * states of these objects at the point where the {@code Window}
1139 * was disposed (not accounting for additional modifications between
1140 * those actions).
3394 Component previousComp = temporaryLostComponent;
3395 // Check that "component" is an acceptable focus owner and don't store it otherwise
3396 // - or later we will have problems with opposite while handling WINDOW_GAINED_FOCUS
3397 if (component == null || component.canBeFocusOwner()) {
3398 temporaryLostComponent = component;
3399 } else {
3400 temporaryLostComponent = null;
3401 }
3402 return previousComp;
3403 }
3404
3405 /**
3406 * Checks whether this window can contain focus owner.
3407 * Verifies that it is focusable and as container it can container focus owner.
3408 * @since 1.5
3409 */
3410 boolean canContainFocusOwner(Component focusOwnerCandidate) {
3411 return super.canContainFocusOwner(focusOwnerCandidate) && isFocusableWindow();
3412 }
3413
3414 private boolean locationByPlatform = locationByPlatformProp;
3415
3416
3417 /**
3418 * Sets whether this Window should appear at the default location for the
3419 * native windowing system or at the current location (returned by
3420 * {@code getLocation}) the next time the Window is made visible.
3421 * This behavior resembles a native window shown without programmatically
3422 * setting its location. Most windowing systems cascade windows if their
3423 * locations are not explicitly set. The actual location is determined once the
3424 * window is shown on the screen.
3425 * <p>
3426 * This behavior can also be enabled by setting the System Property
3427 * "java.awt.Window.locationByPlatform" to "true", though calls to this method
3428 * take precedence.
3429 * <p>
3430 * Calls to {@code setVisible}, {@code setLocation} and
3431 * {@code setBounds} after calling {@code setLocationByPlatform} clear
3432 * this property of the Window.
3433 * <p>
3434 * For example, after the following code is executed:
3465 synchronized (getTreeLock()) {
3466 if (locationByPlatform && isShowing()) {
3467 throw new IllegalComponentStateException("The window is showing on screen.");
3468 }
3469 this.locationByPlatform = locationByPlatform;
3470 }
3471 }
3472
3473 /**
3474 * Returns {@code true} if this Window will appear at the default location
3475 * for the native windowing system the next time this Window is made visible.
3476 * This method always returns {@code false} if the Window is showing on the
3477 * screen.
3478 *
3479 * @return whether this Window will appear at the default location
3480 * @see #setLocationByPlatform
3481 * @see #isShowing
3482 * @since 1.5
3483 */
3484 public boolean isLocationByPlatform() {
3485 synchronized (getTreeLock()) {
3486 return locationByPlatform;
3487 }
3488 }
3489
3490 /**
3491 * {@inheritDoc}
3492 * <p>
3493 * The {@code width} or {@code height} values
3494 * are automatically enlarged if either is less than
3495 * the minimum size as specified by previous call to
3496 * {@code setMinimumSize}.
3497 * <p>
3498 * The method changes the geometry-related data. Therefore,
3499 * the native windowing system may ignore such requests, or it may modify
3500 * the requested data, so that the {@code Window} object is placed and sized
3501 * in a way that corresponds closely to the desktop settings.
3502 *
3503 * @see #getBounds
3504 * @see #setLocation(int, int)
3505 * @see #setLocation(Point)
3506 * @see #setSize(int, int)
3507 * @see #setSize(Dimension)
3508 * @see #setMinimumSize
3556 boolean isRecursivelyVisible() {
3557 // 5079694 fix: for a toplevel to be displayed, its parent doesn't have to be visible.
3558 // We're overriding isRecursivelyVisible to implement this policy.
3559 return visible;
3560 }
3561
3562
3563 // ******************** SHAPES & TRANSPARENCY CODE ********************
3564
3565 /**
3566 * Returns the opacity of the window.
3567 *
3568 * @return the opacity of the window
3569 *
3570 * @see Window#setOpacity(float)
3571 * @see GraphicsDevice.WindowTranslucency
3572 *
3573 * @since 1.7
3574 */
3575 public float getOpacity() {
3576 synchronized (getTreeLock()) {
3577 return opacity;
3578 }
3579 }
3580
3581 /**
3582 * Sets the opacity of the window.
3583 * <p>
3584 * The opacity value is in the range [0..1]. Note that setting the opacity
3585 * level of 0 may or may not disable the mouse event handling on this
3586 * window. This is a platform-dependent behavior.
3587 * <p>
3588 * The following conditions must be met in order to set the opacity value
3589 * less than {@code 1.0f}:
3590 * <ul>
3591 * <li>The {@link GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT}
3592 * translucency must be supported by the underlying system
3593 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
3594 * and {@link Dialog#setUndecorated})
3595 * <li>The window must not be in full-screen mode (see {@link
3596 * GraphicsDevice#setFullScreenWindow(Window)})
3597 * </ul>
3598 * <p>
3599 * If the requested opacity value is less than {@code 1.0f}, and any of the
|
330 */
331 private volatile boolean autoRequestFocus = true;
332
333 /*
334 * Indicates that this window is being shown. This flag is set to true at
335 * the beginning of show() and to false at the end of show().
336 *
337 * @see #show()
338 * @see Dialog#shouldBlock
339 */
340 transient boolean isInShow = false;
341
342 /**
343 * The opacity level of the window
344 *
345 * @serial
346 * @see #setOpacity(float)
347 * @see #getOpacity()
348 * @since 1.7
349 */
350 private volatile float opacity = 1.0f;
351
352 /**
353 * The shape assigned to this window. This field is set to {@code null} if
354 * no shape is set (rectangular window).
355 *
356 * @serial
357 * @see #getShape()
358 * @see #setShape(Shape)
359 * @since 1.7
360 */
361 private Shape shape = null;
362
363 private static final String base = "win";
364 private static int nameCounter = 0;
365
366 /*
367 * JDK 1.1 serialVersionUID
368 */
369 private static final long serialVersionUID = 4497834738069338734L;
370
1023 * @see Component#isDisplayable
1024 * @see #toFront
1025 * @deprecated As of JDK version 1.5, replaced by
1026 * {@link #setVisible(boolean)}.
1027 */
1028 @Deprecated
1029 public void show() {
1030 if (peer == null) {
1031 addNotify();
1032 }
1033 validateUnconditionally();
1034
1035 isInShow = true;
1036 if (visible) {
1037 toFront();
1038 } else {
1039 beforeFirstShow = false;
1040 closeSplashScreen();
1041 Dialog.checkShouldBeBlocked(this);
1042 super.show();
1043 locationByPlatform = false;
1044 for (int i = 0; i < ownedWindowList.size(); i++) {
1045 Window child = ownedWindowList.elementAt(i).get();
1046 if ((child != null) && child.showWithParent) {
1047 child.show();
1048 child.showWithParent = false;
1049 } // endif
1050 } // endfor
1051 if (!isModalBlocked()) {
1052 updateChildrenBlocking();
1053 } else {
1054 // fix for 6532736: after this window is shown, its blocker
1055 // should be raised to front
1056 modalBlocker.toFront_NoClientCode();
1057 }
1058 if (this instanceof Frame || this instanceof Dialog) {
1059 updateChildFocusableWindowState(this);
1060 }
1061 }
1062 isInShow = false;
1063
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();
1116 locationByPlatform = false;
1117 }
1118
1119 final void clearMostRecentFocusOwnerOnHide() {
1120 /* do nothing */
1121 }
1122
1123 /**
1124 * Releases all of the native screen resources used by this
1125 * {@code Window}, its subcomponents, and all of its owned
1126 * children. That is, the resources for these {@code Component}s
1127 * will be destroyed, any memory they consume will be returned to the
1128 * OS, and they will be marked as undisplayable.
1129 * <p>
1130 * The {@code Window} and its subcomponents can be made displayable
1131 * again by rebuilding the native resources with a subsequent call to
1132 * {@code pack} or {@code show}. The states of the recreated
1133 * {@code Window} and its subcomponents will be identical to the
1134 * states of these objects at the point where the {@code Window}
1135 * was disposed (not accounting for additional modifications between
1136 * those actions).
3390 Component previousComp = temporaryLostComponent;
3391 // Check that "component" is an acceptable focus owner and don't store it otherwise
3392 // - or later we will have problems with opposite while handling WINDOW_GAINED_FOCUS
3393 if (component == null || component.canBeFocusOwner()) {
3394 temporaryLostComponent = component;
3395 } else {
3396 temporaryLostComponent = null;
3397 }
3398 return previousComp;
3399 }
3400
3401 /**
3402 * Checks whether this window can contain focus owner.
3403 * Verifies that it is focusable and as container it can container focus owner.
3404 * @since 1.5
3405 */
3406 boolean canContainFocusOwner(Component focusOwnerCandidate) {
3407 return super.canContainFocusOwner(focusOwnerCandidate) && isFocusableWindow();
3408 }
3409
3410 private volatile boolean locationByPlatform = locationByPlatformProp;
3411
3412
3413 /**
3414 * Sets whether this Window should appear at the default location for the
3415 * native windowing system or at the current location (returned by
3416 * {@code getLocation}) the next time the Window is made visible.
3417 * This behavior resembles a native window shown without programmatically
3418 * setting its location. Most windowing systems cascade windows if their
3419 * locations are not explicitly set. The actual location is determined once the
3420 * window is shown on the screen.
3421 * <p>
3422 * This behavior can also be enabled by setting the System Property
3423 * "java.awt.Window.locationByPlatform" to "true", though calls to this method
3424 * take precedence.
3425 * <p>
3426 * Calls to {@code setVisible}, {@code setLocation} and
3427 * {@code setBounds} after calling {@code setLocationByPlatform} clear
3428 * this property of the Window.
3429 * <p>
3430 * For example, after the following code is executed:
3461 synchronized (getTreeLock()) {
3462 if (locationByPlatform && isShowing()) {
3463 throw new IllegalComponentStateException("The window is showing on screen.");
3464 }
3465 this.locationByPlatform = locationByPlatform;
3466 }
3467 }
3468
3469 /**
3470 * Returns {@code true} if this Window will appear at the default location
3471 * for the native windowing system the next time this Window is made visible.
3472 * This method always returns {@code false} if the Window is showing on the
3473 * screen.
3474 *
3475 * @return whether this Window will appear at the default location
3476 * @see #setLocationByPlatform
3477 * @see #isShowing
3478 * @since 1.5
3479 */
3480 public boolean isLocationByPlatform() {
3481 return locationByPlatform;
3482 }
3483
3484 /**
3485 * {@inheritDoc}
3486 * <p>
3487 * The {@code width} or {@code height} values
3488 * are automatically enlarged if either is less than
3489 * the minimum size as specified by previous call to
3490 * {@code setMinimumSize}.
3491 * <p>
3492 * The method changes the geometry-related data. Therefore,
3493 * the native windowing system may ignore such requests, or it may modify
3494 * the requested data, so that the {@code Window} object is placed and sized
3495 * in a way that corresponds closely to the desktop settings.
3496 *
3497 * @see #getBounds
3498 * @see #setLocation(int, int)
3499 * @see #setLocation(Point)
3500 * @see #setSize(int, int)
3501 * @see #setSize(Dimension)
3502 * @see #setMinimumSize
3550 boolean isRecursivelyVisible() {
3551 // 5079694 fix: for a toplevel to be displayed, its parent doesn't have to be visible.
3552 // We're overriding isRecursivelyVisible to implement this policy.
3553 return visible;
3554 }
3555
3556
3557 // ******************** SHAPES & TRANSPARENCY CODE ********************
3558
3559 /**
3560 * Returns the opacity of the window.
3561 *
3562 * @return the opacity of the window
3563 *
3564 * @see Window#setOpacity(float)
3565 * @see GraphicsDevice.WindowTranslucency
3566 *
3567 * @since 1.7
3568 */
3569 public float getOpacity() {
3570 return opacity;
3571 }
3572
3573 /**
3574 * Sets the opacity of the window.
3575 * <p>
3576 * The opacity value is in the range [0..1]. Note that setting the opacity
3577 * level of 0 may or may not disable the mouse event handling on this
3578 * window. This is a platform-dependent behavior.
3579 * <p>
3580 * The following conditions must be met in order to set the opacity value
3581 * less than {@code 1.0f}:
3582 * <ul>
3583 * <li>The {@link GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT}
3584 * translucency must be supported by the underlying system
3585 * <li>The window must be undecorated (see {@link Frame#setUndecorated}
3586 * and {@link Dialog#setUndecorated})
3587 * <li>The window must not be in full-screen mode (see {@link
3588 * GraphicsDevice#setFullScreenWindow(Window)})
3589 * </ul>
3590 * <p>
3591 * If the requested opacity value is less than {@code 1.0f}, and any of the
|