diff -r 06d6f1977762 -r e7c280629f58 jdk/src/share/classes/java/awt/Frame.java --- a/jdk/src/share/classes/java/awt/Frame.java Thu Nov 18 14:26:19 2010 +0300 +++ b/jdk/src/share/classes/java/awt/Frame.java Thu Nov 25 13:23:49 2010 +0300 @@ -879,15 +879,32 @@ /** * Disables or enables decorations for this frame. - * This method can only be called while the frame is not displayable. - * @param undecorated true if no frame decorations are - * to be enabled; - * false if frame decorations are to be enabled. - * @throws IllegalComponentStateException if the frame - * is displayable. + *

+ * This method can only be called while the frame is not displayable. To + * make this frame decorated, it must be opaque and have the default shape, + * otherwise the {@code IllegalComponentStateException} will be thrown. + * Refer to {@link Window#setShape}, {@link Window#setOpacity} and {@link + * Window#setBackground} for details + * + * @param undecorated {@code true} if no frame decorations are to be + * enabled; {@code false} if frame decorations are to be enabled + * + * @throws IllegalComponentStateException if the frame is displayable + * @throws IllegalComponentStateException if {@code undecorated} is + * {@code false}, and this frame does not have the default shape + * @throws IllegalComponentStateException if {@code undecorated} is + * {@code false}, and this frame opacity is less than {@code 1.0f} + * @throws IllegalComponentStateException if {@code undecorated} is + * {@code false}, and the alpha value of this frame background + * color is less than {@code 1.0f} + * * @see #isUndecorated * @see Component#isDisplayable + * @see Window#getShape + * @see Window#getOpacity + * @see Window#getBackground * @see javax.swing.JFrame#setDefaultLookAndFeelDecorated(boolean) + * * @since 1.4 */ public void setUndecorated(boolean undecorated) { @@ -896,6 +913,18 @@ if (isDisplayable()) { throw new IllegalComponentStateException("The frame is displayable."); } + if (!undecorated) { + if (getOpacity() < 1.0f) { + throw new IllegalComponentStateException("The frame is not opaque"); + } + if (getShape() != null) { + throw new IllegalComponentStateException("The frame does not have a default shape"); + } + Color bg = getBackground(); + if ((bg != null) && (bg.getAlpha() < 255)) { + throw new IllegalComponentStateException("The frame background color is not opaque"); + } + } this.undecorated = undecorated; } } @@ -913,6 +942,45 @@ } /** + * {@inheritDoc} + */ + @Override + public void setOpacity(float opacity) { + synchronized (getTreeLock()) { + if ((opacity < 1.0f) && !isUndecorated()) { + throw new IllegalComponentStateException("The frame is decorated"); + } + super.setOpacity(opacity); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setShape(Shape shape) { + synchronized (getTreeLock()) { + if ((shape != null) && !isUndecorated()) { + throw new IllegalComponentStateException("The frame is decorated"); + } + super.setShape(shape); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setBackground(Color bgColor) { + synchronized (getTreeLock()) { + if ((bgColor != null) && (bgColor.getAlpha() < 255) && !isUndecorated()) { + throw new IllegalComponentStateException("The frame is decorated"); + } + super.setBackground(bgColor); + } + } + + /** * Removes the specified menu bar from this frame. * @param m the menu component to remove. * If m is null, then