SUGGESTED FIX
--- old/src/share/classes/com/sun/awt/AWTUtilities.java 2008-07-25 14:17:12.000000000 +0400
+++ new/src/share/classes/com/sun/awt/AWTUtilities.java 2008-07-25 14:17:12.000000000 +0400
@@ -340,6 +340,13 @@
* <p>Also note that the window must not be in the full-screen mode
* when making it non-opaque. Otherwise the IllegalArgumentException
* is thrown.
+ * <p>If the window is a {@code Frame} or a {@code Dialog}, the window must
+ * be undecorated prior to enabling the per-pixel translucency effect (see
+ * {@link Frame#setUndecorated()} and/or {@link Dialog#setUndecorated()}).
+ * If the window becomes decorated through a subsequent call to the
+ * corresponding {@code setUndecorated()} method, the per-pixel
+ * translucency effect will be disabled and the opaque property reset to
+ * {@code true}.
* <p>Depending on the platform, the method may return without
* effecting the opaque property of the window if the window has a non-null
* warning string ({@link Window#getWarningString()}). In this case
@@ -355,6 +362,7 @@
* method returns false
* @throws IllegalArgumentException if the window is in full screen mode,
* and the isOpaque is false
+ * @throws IllegalArgumentException if the window is decorated.
* @throws UnsupportedOperationException if the PERPIXEL_TRANSLUCENT
* translucency kind is not supported
*/
@@ -363,17 +371,24 @@
throw new NullPointerException(
"The window argument should not be null.");
}
- if (!isTranslucencyCapable(
+ if (!isOpaque && !isTranslucencyCapable(
window.getGraphicsConfiguration())) {
throw new IllegalArgumentException(
"The window must use a translucency-compatible graphics configuration");
}
- if (window.getGraphicsConfiguration().getDevice().getFullScreenWindow()
- == window && !isOpaque) {
+ if (!isOpaque && window.getGraphicsConfiguration().getDevice().getFullScreenWindow()
+ == window) {
throw new IllegalArgumentException(
"The effects for full-screen windows are not supported.");
}
- if (!isTranslucencySupported(Translucency.PERPIXEL_TRANSLUCENT)) {
+ if (!isOpaque &&
+ ((window instanceof Frame && !((Frame)window).isUndecorated()) ||
+ (window instanceof Dialog && !((Dialog)window).isUndecorated())))
+ {
+ throw new IllegalArgumentException(
+ "The effects for decorated windows are not supported.");
+ }
+ if (!isOpaque && !isTranslucencySupported(Translucency.PERPIXEL_TRANSLUCENT)) {
throw new UnsupportedOperationException(
"The PERPIXEL_TRANSLUCENT translucency kind is not supported");
}
--- old/src/share/classes/java/awt/Dialog.java 2008-07-25 14:17:12.000000000 +0400
+++ new/src/share/classes/java/awt/Dialog.java 2008-07-25 14:17:12.000000000 +0400
@@ -15,6 +15,7 @@
import java.util.Vector;
import java.util.Iterator;
import sun.awt.AppContext;
+import sun.awt.AWTAccessor;
import sun.awt.SunToolkit;
import sun.awt.PeerEvent;
import java.lang.ref.WeakReference;
@@ -1321,6 +1322,16 @@
if (isDisplayable()) {
throw new IllegalComponentStateException("The dialog is displayable.");
}
+ if (!undecorated) {
+ //XXX: this needs to be documented in a further release,
+ //or better: we may throw an exception here.
+ if (!AWTAccessor.getWindowAccessor().isOpaque(this)) {
+ AWTAccessor.getWindowAccessor().setOpaque(this, true);
+ }
+ if (AWTAccessor.getWindowAccessor().getShape(this) != null) {
+ AWTAccessor.getWindowAccessor().setShape(this, null);
+ }
+ }
this.undecorated = undecorated;
}
}
--- old/src/share/classes/java/awt/Frame.java 2008-07-25 14:17:13.000000000 +0400
+++ new/src/share/classes/java/awt/Frame.java 2008-07-25 14:17:13.000000000 +0400
@@ -18,6 +18,7 @@
import java.io.IOException;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
+import sun.awt.AWTAccessor;
import java.lang.ref.WeakReference;
import javax.accessibility.*;
@@ -809,6 +810,16 @@
if (isDisplayable()) {
throw new IllegalComponentStateException("The frame is displayable.");
}
+ if (!undecorated) {
+ //XXX: this needs to be documented in a further release,
+ //or better: we may throw an exception here.
+ if (!AWTAccessor.getWindowAccessor().isOpaque(this)) {
+ AWTAccessor.getWindowAccessor().setOpaque(this, true);
+ }
+ if (AWTAccessor.getWindowAccessor().getShape(this) != null) {
+ AWTAccessor.getWindowAccessor().setShape(this, null);
+ }
+ }
this.undecorated = undecorated;
}
}
|