diff --git a/jdk/make/sun/xawt/mapfile-vers b/jdk/make/sun/xawt/mapfile-vers index 0d951efff1d..920d829fc93 100644 --- a/jdk/make/sun/xawt/mapfile-vers +++ b/jdk/make/sun/xawt/mapfile-vers @@ -432,6 +432,7 @@ SUNWprivate_1.1 { Java_sun_awt_X11_GtkFileDialogPeer_initIDs; Java_sun_awt_X11_GtkFileDialogPeer_run; Java_sun_awt_X11_GtkFileDialogPeer_quit; + Java_sun_awt_X11_GtkFileDialogPeer_toFront; Java_sun_print_CUPSPrinter_initIDs; Java_sun_print_CUPSPrinter_getCupsServer; diff --git a/jdk/src/share/classes/java/awt/Color.java b/jdk/src/share/classes/java/awt/Color.java index 8cbe667ca00..2ff9a6d5e1b 100644 --- a/jdk/src/share/classes/java/awt/Color.java +++ b/jdk/src/share/classes/java/awt/Color.java @@ -611,12 +611,15 @@ public class Color implements Paint, java.io.Serializable { *
* This method applies an arbitrary scale factor to each of the three RGB
* components of this Color to create a brighter version
- * of this Color. Although brighter and
+ * of this Color.
+ * The {@code alpha} value is preserved.
+ * Although brighter and
* darker are inverse operations, the results of a
* series of invocations of these two methods might be inconsistent
* because of rounding errors.
* @return a new Color object that is
- * a brighter version of this Color.
+ * a brighter version of this Color
+ * with the same {@code alpha} value.
* @see java.awt.Color#darker
* @since JDK1.0
*/
@@ -624,6 +627,7 @@ public class Color implements Paint, java.io.Serializable {
int r = getRed();
int g = getGreen();
int b = getBlue();
+ int alpha = getAlpha();
/* From 2D group:
* 1. black.brighter() should return grey
@@ -632,7 +636,7 @@ public class Color implements Paint, java.io.Serializable {
*/
int i = (int)(1.0/(1.0-FACTOR));
if ( r == 0 && g == 0 && b == 0) {
- return new Color(i, i, i);
+ return new Color(i, i, i, alpha);
}
if ( r > 0 && r < i ) r = i;
if ( g > 0 && g < i ) g = i;
@@ -640,7 +644,8 @@ public class Color implements Paint, java.io.Serializable {
return new Color(Math.min((int)(r/FACTOR), 255),
Math.min((int)(g/FACTOR), 255),
- Math.min((int)(b/FACTOR), 255));
+ Math.min((int)(b/FACTOR), 255),
+ alpha);
}
/**
@@ -649,19 +654,23 @@ public class Color implements Paint, java.io.Serializable {
*
* This method applies an arbitrary scale factor to each of the three RGB
* components of this Color to create a darker version of
- * this Color. Although brighter and
+ * this Color.
+ * The {@code alpha} value is preserved.
+ * Although brighter and
* darker are inverse operations, the results of a series
* of invocations of these two methods might be inconsistent because
* of rounding errors.
* @return a new Color object that is
- * a darker version of this Color.
+ * a darker version of this Color
+ * with the same {@code alpha} value.
* @see java.awt.Color#brighter
* @since JDK1.0
*/
public Color darker() {
return new Color(Math.max((int)(getRed() *FACTOR), 0),
Math.max((int)(getGreen()*FACTOR), 0),
- Math.max((int)(getBlue() *FACTOR), 0));
+ Math.max((int)(getBlue() *FACTOR), 0),
+ getAlpha());
}
/**
diff --git a/jdk/src/share/classes/java/awt/Container.java b/jdk/src/share/classes/java/awt/Container.java
index a7ee77e16cb..8a463b005e4 100644
--- a/jdk/src/share/classes/java/awt/Container.java
+++ b/jdk/src/share/classes/java/awt/Container.java
@@ -51,6 +51,7 @@ import javax.accessibility.*;
import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
+import sun.awt.AWTAccessor;
import sun.awt.CausedFocusEvent;
import sun.awt.PeerEvent;
import sun.awt.SunToolkit;
@@ -247,6 +248,13 @@ public class Container extends Component {
if (!GraphicsEnvironment.isHeadless()) {
initIDs();
}
+
+ AWTAccessor.setContainerAccessor(new AWTAccessor.ContainerAccessor() {
+ @Override
+ public void validateUnconditionally(Container cont) {
+ cont.validateUnconditionally();
+ }
+ });
}
/**
diff --git a/jdk/src/share/classes/java/awt/Dialog.java b/jdk/src/share/classes/java/awt/Dialog.java
index 36a3502e3ba..26164ec5675 100644
--- a/jdk/src/share/classes/java/awt/Dialog.java
+++ b/jdk/src/share/classes/java/awt/Dialog.java
@@ -1248,14 +1248,31 @@ public class Dialog extends Window {
/**
* Disables or enables decorations for this dialog.
- * This method can only be called while the dialog is not displayable.
- * @param undecorated true if no dialog decorations are
- * to be enabled;
- * false if dialog decorations are to be enabled.
- * @throws IllegalComponentStateException if the dialog
- * is displayable.
+ *
+ * This method can only be called while the dialog is not displayable. To
+ * make this dialog 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 dialog decorations are to be
+ * enabled; {@code false} if dialog decorations are to be enabled
+ *
+ * @throws IllegalComponentStateException if the dialog is displayable
+ * @throws IllegalComponentStateException if {@code undecorated} is
+ * {@code false}, and this dialog does not have the default shape
+ * @throws IllegalComponentStateException if {@code undecorated} is
+ * {@code false}, and this dialog opacity is less than {@code 1.0f}
+ * @throws IllegalComponentStateException if {@code undecorated} is
+ * {@code false}, and the alpha value of this dialog background
+ * color is less than {@code 1.0f}
+ *
* @see #isUndecorated
* @see Component#isDisplayable
+ * @see Window#getShape
+ * @see Window#getOpacity
+ * @see Window#getBackground
+ *
* @since 1.4
*/
public void setUndecorated(boolean undecorated) {
@@ -1264,6 +1281,18 @@ public class Dialog extends Window {
if (isDisplayable()) {
throw new IllegalComponentStateException("The dialog is displayable.");
}
+ if (!undecorated) {
+ if (getOpacity() < 1.0f) {
+ throw new IllegalComponentStateException("The dialog is not opaque");
+ }
+ if (getShape() != null) {
+ throw new IllegalComponentStateException("The dialog does not have a default shape");
+ }
+ Color bg = getBackground();
+ if ((bg != null) && (bg.getAlpha() < 255)) {
+ throw new IllegalComponentStateException("The dialog background color is not opaque");
+ }
+ }
this.undecorated = undecorated;
}
}
@@ -1280,6 +1309,45 @@ public class Dialog extends Window {
return undecorated;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setOpacity(float opacity) {
+ synchronized (getTreeLock()) {
+ if ((opacity < 1.0f) && !isUndecorated()) {
+ throw new IllegalComponentStateException("The dialog is decorated");
+ }
+ super.setOpacity(opacity);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setShape(Shape shape) {
+ synchronized (getTreeLock()) {
+ if ((shape != null) && !isUndecorated()) {
+ throw new IllegalComponentStateException("The dialog 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 dialog is decorated");
+ }
+ super.setBackground(bgColor);
+ }
+ }
+
/**
* Returns a string representing the state of this dialog. This
* method is intended to be used only for debugging purposes, and the
diff --git a/jdk/src/share/classes/java/awt/FileDialog.java b/jdk/src/share/classes/java/awt/FileDialog.java
index 033b7660d0e..5e35bfe2ea9 100644
--- a/jdk/src/share/classes/java/awt/FileDialog.java
+++ b/jdk/src/share/classes/java/awt/FileDialog.java
@@ -99,7 +99,7 @@ public class FileDialog extends Dialog {
* Contains the File instances for all the files that the user selects.
*
* @serial
- * @see getFiles
+ * @see #getFiles
* @since 1.7
*/
private File[] files;
diff --git a/jdk/src/share/classes/java/awt/Frame.java b/jdk/src/share/classes/java/awt/Frame.java
index f69e02f5239..bd2539f055b 100644
--- a/jdk/src/share/classes/java/awt/Frame.java
+++ b/jdk/src/share/classes/java/awt/Frame.java
@@ -828,6 +828,11 @@ public class Frame extends Window implements MenuContainer {
return frame.state;
}
}
+ public Rectangle getMaximizedBounds(Frame frame) {
+ synchronized(frame.getObjectLock()) {
+ return frame.maximizedBounds;
+ }
+ }
}
);
}
@@ -855,8 +860,10 @@ public class Frame extends Window implements MenuContainer {
* @see #getMaximizedBounds()
* @since 1.4
*/
- public synchronized void setMaximizedBounds(Rectangle bounds) {
- this.maximizedBounds = bounds;
+ public void setMaximizedBounds(Rectangle bounds) {
+ synchronized(getObjectLock()) {
+ this.maximizedBounds = bounds;
+ }
FramePeer peer = (FramePeer)this.peer;
if (peer != null) {
peer.setMaximizedBounds(bounds);
@@ -873,21 +880,40 @@ public class Frame extends Window implements MenuContainer {
* @since 1.4
*/
public Rectangle getMaximizedBounds() {
- return maximizedBounds;
+ synchronized(getObjectLock()) {
+ return maximizedBounds;
+ }
}
/**
* 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 +922,18 @@ public class Frame extends Window implements MenuContainer { 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; } } @@ -912,6 +950,45 @@ public class Frame extends Window implements MenuContainer { return undecorated; } + /** + * {@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. diff --git a/jdk/src/share/classes/java/awt/Window.java b/jdk/src/share/classes/java/awt/Window.java index 03dbd535e9f..064c8494f4e 100644 --- a/jdk/src/share/classes/java/awt/Window.java +++ b/jdk/src/share/classes/java/awt/Window.java @@ -3474,14 +3474,20 @@ public class Window extends Container implements Accessible { * level of 0 may or may not disable the mouse event handling on this * window. This is a platform-dependent behavior. *
- * In order for this method to enable the translucency effect, the {@link - * GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)} method must indicate that - * the {@link GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT} - * translucency is supported. + * The following conditions must be met in order to set the opacity value + * less than {@code 1.0f}: + *
- * Also note that the window must not be in the full-screen mode when - * setting the opacity value < 1.0f. Otherwise the {@code - * IllegalComponentStateException} is thrown. + * If the requested opacity value is less than {@code 1.0f}, and any of the + * above conditions are not met, the window opacity will not change, + * and the {@code IllegalComponentStateException} will be thrown. *
* The translucency levels of individual pixels may also be effected by the * alpha component of their color (see {@link Window#setBackground(Color)}) and the @@ -3491,15 +3497,20 @@ public class Window extends Container implements Accessible { * * @throws IllegalArgumentException if the opacity is out of the range * [0..1] + * @throws IllegalComponentStateException if the window is decorated and + * the opacity is less than {@code 1.0f} * @throws IllegalComponentStateException if the window is in full screen - * mode, and the opacity is less than 1.0f + * mode, and the opacity is less than {@code 1.0f} * @throws UnsupportedOperationException if the {@code * GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT} - * translucency kind is not supported and the opacity is less than 1.0f + * translucency is not supported and the opacity is less than + * {@code 1.0f} * * @see Window#getOpacity * @see Window#setBackground(Color) * @see Window#setShape(Shape) + * @see Frame#isUndecorated + * @see Dialog#isUndecorated * @see GraphicsDevice.WindowTranslucency * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency) * @@ -3557,24 +3568,26 @@ public class Window extends Container implements Accessible { /** * Sets the shape of the window. *
- * Setting a shape enables cutting off some parts of the window, leaving - * visible and clickable only those parts belonging to the given shape - * (see {@link Shape}). If the shape argument is null, this methods - * restores the default shape (making the window rectangular on most - * platforms.) + * Setting a shape cuts off some parts of the window. Only the parts that + * belong to the given {@link Shape} remain visible and clickable. If + * the shape argument is {@code null}, this method restores the default + * shape, making the window rectangular on most platforms. *
- * The following conditions must be met in order to set a non-null shape: + * The following conditions must be met to set a non-null shape: *
+ * If the requested shape is not {@code null}, and any of the above + * conditions are not met, the shape of this window will not change, + * and either the {@code UnsupportedOperationException} or {@code + * IllegalComponentStateException} will be thrown. *
* The tranlucency levels of individual pixels may also be effected by the * alpha component of their color (see {@link Window#setBackground(Color)}) and the @@ -3584,6 +3597,8 @@ public class Window extends Container implements Accessible { * @param shape the shape to set to the window * * @throws IllegalComponentStateException if the shape is not {@code + * null} and the window is decorated + * @throws IllegalComponentStateException if the shape is not {@code * null} and the window is in full-screen mode * @throws UnsupportedOperationException if the shape is not {@code * null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT @@ -3592,6 +3607,8 @@ public class Window extends Container implements Accessible { * @see Window#getShape() * @see Window#setBackground(Color) * @see Window#setOpacity(float) + * @see Frame#isUndecorated + * @see Dialog#isUndecorated * @see GraphicsDevice.WindowTranslucency * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency) * @@ -3645,37 +3662,46 @@ public class Window extends Container implements Accessible { * GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT PERPIXEL_TRANSLUCENT} * tranclucency, the alpha component of the given background color * may effect the mode of operation for this window: it indicates whether - * this window must be opaque (alpha == 1.0f) or per-pixel translucent - * (alpha < 1.0f). All the following conditions must be met in order - * to be able to enable the per-pixel transparency mode for this window: + * this window must be opaque (alpha equals {@code 1.0f}) or per-pixel translucent + * (alpha is less than {@code 1.0f}). If the given background color is + * {@code null}, the window is considered completely opaque. + *
+ * All the following conditions must be met to enable the per-pixel + * transparency mode for this window: *
+ * If the alpha component of the requested background color is less than + * {@code 1.0f}, and any of the above conditions are not met, the background + * color of this window will not change, the alpha component of the given + * background color will not affect the mode of operation for this window, + * and either the {@code UnsupportedOperationException} or {@code + * IllegalComponentStateException} will be thrown. *
* When the window is per-pixel translucent, the drawing sub-system * respects the alpha value of each individual pixel. If a pixel gets * painted with the alpha color component equal to zero, it becomes - * visually transparent, if the alpha of the pixel is equal to 1.0f, the + * visually transparent. If the alpha of the pixel is equal to 1.0f, the * pixel is fully opaque. Interim values of the alpha color component make - * the pixel semi-transparent. In this mode the background of the window - * gets painted with the alpha value of the given background color (meaning - * that it is not painted at all if the alpha value of the argument of this - * method is equal to zero.) + * the pixel semi-transparent. In this mode, the background of the window + * gets painted with the alpha value of the given background color. If the + * alpha value of the argument of this method is equal to {@code 0}, the + * background is not painted at all. *
* The actual level of translucency of a given pixel also depends on window * opacity (see {@link #setOpacity(float)}), as well as the current shape of * this window (see {@link #setShape(Shape)}). *
- * Note that painting a pixel with the alpha value of 0 may or may not - * disable the mouse event handling on this pixel. This is a - * platform-dependent behavior. To make sure the mouse clicks do not get + * Note that painting a pixel with the alpha value of {@code 0} may or may + * not disable the mouse event handling on this pixel. This is a + * platform-dependent behavior. To make sure the mouse events do not get * dispatched to a particular pixel, the pixel must be excluded from the * shape of the window. *
@@ -3685,17 +3711,21 @@ public class Window extends Container implements Accessible { * @param bgColor the color to become this window's background color. * * @throws IllegalComponentStateException if the alpha value of the given - * background color is less than 1.0f and the window is in + * background color is less than {@code 1.0f} and the window is decorated + * @throws IllegalComponentStateException if the alpha value of the given + * background color is less than {@code 1.0f} and the window is in * full-screen mode * @throws UnsupportedOperationException if the alpha value of the given - * background color is less than 1.0f and - * {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT + * background color is less than {@code 1.0f} and {@link + * GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT * PERPIXEL_TRANSLUCENT} translucency is not supported * * @see Window#getBackground * @see Window#isOpaque * @see Window#setOpacity(float) * @see Window#setShape(Shape) + * @see Frame#isUndecorated + * @see Dialog#isUndecorated * @see GraphicsDevice.WindowTranslucency * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency) * @see GraphicsConfiguration#isTranslucencyCapable() @@ -3739,7 +3769,7 @@ public class Window extends Container implements Accessible { *
* 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. + * {@code 1.0f}. The method returns {@code true} otherwise. * * @return {@code true} if the window is opaque, {@code false} otherwise * diff --git a/jdk/src/share/classes/sun/awt/AWTAccessor.java b/jdk/src/share/classes/sun/awt/AWTAccessor.java index b9171ce9798..abef250993d 100644 --- a/jdk/src/share/classes/sun/awt/AWTAccessor.java +++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java @@ -223,6 +223,16 @@ public final class AWTAccessor { void processEvent(Component comp, AWTEvent e); } + /* + * An interface of accessor for the java.awt.Container class. + */ + public interface ContainerAccessor { + /** + * Validates the container unconditionally. + */ + void validateUnconditionally(Container cont); + } + /* * An interface of accessor for java.awt.Window class. */ @@ -334,6 +344,10 @@ public final class AWTAccessor { * Gets the state of this frame. */ int getExtendedState(Frame frame); + /* + * Gets the maximized bounds of this frame. + */ + Rectangle getMaximizedBounds(Frame frame); } /* @@ -440,53 +454,19 @@ public final class AWTAccessor { } /* - * The java.awt.Component class accessor object. + * Accessor instances are initialized in the static initializers of + * corresponding AWT classes by using setters defined below. */ private static ComponentAccessor componentAccessor; - - /* - * The java.awt.Window class accessor object. - */ + private static ContainerAccessor containerAccessor; private static WindowAccessor windowAccessor; - - /* - * The java.awt.AWTEvent class accessor object. - */ private static AWTEventAccessor awtEventAccessor; - - /* - * The java.awt.event.InputEvent class accessor object. - */ private static InputEventAccessor inputEventAccessor; - - /* - * The java.awt.Frame class accessor object. - */ private static FrameAccessor frameAccessor; - - /* - * The java.awt.KeyboardFocusManager class accessor object. - */ private static KeyboardFocusManagerAccessor kfmAccessor; - - /* - * The java.awt.MenuComponent class accessor object. - */ private static MenuComponentAccessor menuComponentAccessor; - - /* - * The java.awt.EventQueue class accessor object. - */ private static EventQueueAccessor eventQueueAccessor; - - /* - * The java.awt.PopupMenu class accessor object. - */ private static PopupMenuAccessor popupMenuAccessor; - - /* - * The java.awt.FileDialog class accessor object. - */ private static FileDialogAccessor fileDialogAccessor; /* @@ -497,7 +477,7 @@ public final class AWTAccessor { } /* - * Retrieve the accessor object for the java.awt.Window class. + * Retrieve the accessor object for the java.awt.Component class. */ public static ComponentAccessor getComponentAccessor() { if (componentAccessor == null) { @@ -507,6 +487,24 @@ public final class AWTAccessor { return componentAccessor; } + /* + * Set an accessor object for the java.awt.Container class. + */ + public static void setContainerAccessor(ContainerAccessor ca) { + containerAccessor = ca; + } + + /* + * Retrieve the accessor object for the java.awt.Container class. + */ + public static ContainerAccessor getContainerAccessor() { + if (containerAccessor == null) { + unsafe.ensureClassInitialized(Container.class); + } + + return containerAccessor; + } + /* * Set an accessor object for the java.awt.Window class. */ diff --git a/jdk/src/share/demo/applets/NervousText/example1.html b/jdk/src/share/demo/applets/NervousText/example1.html index 38e4f840da5..96013da6f45 100644 --- a/jdk/src/share/demo/applets/NervousText/example1.html +++ b/jdk/src/share/demo/applets/NervousText/example1.html @@ -1,7 +1,7 @@