--- a/jdk/src/share/classes/java/awt/Window.java Sun Jul 12 23:20:26 2009 -0700
+++ b/jdk/src/share/classes/java/awt/Window.java Tue Jul 14 14:08:47 2009 +0400
@@ -3521,6 +3521,7 @@
* @return this component's background color
*
* @see Window#setBackground
+ * @see Window#isOpaque
* @see GraphicsDevice.WindowTranslucency
*/
@Override
@@ -3583,6 +3584,7 @@
* PERPIXEL_TRANSLUCENT} translucency is not supported
*
* @see Window#getBackground
+ * @see Window#isOpaque
* @see Window#setOpacity()
* @see Window#setShape()
* @see GraphicsDevice.WindowTranslucency
@@ -3623,6 +3625,25 @@
}
}
+ /**
+ * Indicates if the window is currently opaque.
+ * <p>
+ * The method returns {@code false} if the background color of the window
+ * is not {@code null} and the alpha component of the color is less than
+ * 1.0f. The method returns {@code true} otherwise.
+ *
+ * @return {@code true} if the window is opaque, {@code false} otherwise
+ *
+ * @see Window#getBackground
+ * @see Window#setBackground
+ * @since 1.7
+ */
+ @Override
+ public boolean isOpaque() {
+ Color bg = getBackground();
+ return bg != null ? bg.getAlpha() == 255 : true;
+ }
+
private void updateWindow() {
synchronized (getTreeLock()) {
WindowPeer peer = (WindowPeer)getPeer();
@@ -3639,12 +3660,11 @@
*/
@Override
public void paint(Graphics g) {
- Color bgColor = getBackground();
- if ((bgColor != null) && (bgColor.getAlpha() < 255)) {
+ if (!isOpaque()) {
Graphics gg = g.create();
try {
if (gg instanceof Graphics2D) {
- gg.setColor(bgColor);
+ gg.setColor(getBackground());
((Graphics2D)gg).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC));
gg.fillRect(0, 0, getWidth(), getHeight());
}
@@ -3749,10 +3769,6 @@
public void setShape(Window window, Shape shape) {
window.setShape(shape);
}
- public boolean isOpaque(Window window) {
- Color bg = window.getBackground();
- return (bg != null) ? bg.getAlpha() == 255 : true;
- }
public void setOpaque(Window window, boolean opaque) {
Color bg = window.getBackground();
if (bg == null) {