mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
8186617: The "com.sun.awt.AWTUtilities" class can be dropped in favour of public API
Reviewed-by: azvegint, prr
This commit is contained in:
parent
a569f5293b
commit
66812b5f48
17 changed files with 507 additions and 652 deletions
|
@ -25,19 +25,19 @@
|
||||||
|
|
||||||
package com.apple.eawt;
|
package com.apple.eawt;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Component;
|
||||||
|
import java.awt.Window;
|
||||||
|
|
||||||
import javax.swing.RootPaneContainer;
|
import javax.swing.RootPaneContainer;
|
||||||
|
|
||||||
import sun.lwawt.macosx.*;
|
|
||||||
|
|
||||||
import com.apple.eawt.event.GestureUtilities;
|
import com.apple.eawt.event.GestureUtilities;
|
||||||
|
import sun.lwawt.macosx.CPlatformWindow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class perform animated full screen actions to top-level {@link Window}s.
|
* Utility class perform animated full screen actions to top-level {@link Window}s.
|
||||||
*
|
*
|
||||||
* This class manages the relationship between {@link Window}s and the {@link FullScreenListener}s
|
* This class manages the relationship between {@link Window}s and the {@link FullScreenListener}s
|
||||||
* attached to them. It's design is similar to the Java SE 6u10 {@link com.sun.awt.AWTUtilities}
|
* attached to them. It's design is similar to the Java SE 6u10 {@code com.sun.awt.AWTUtilities}
|
||||||
* class which adds additional functionality to AWT Windows, without adding new API to the
|
* class which adds additional functionality to AWT Windows, without adding new API to the
|
||||||
* {@link java.awt.Window} class.
|
* {@link java.awt.Window} class.
|
||||||
*
|
*
|
||||||
|
@ -45,7 +45,6 @@ import com.apple.eawt.event.GestureUtilities;
|
||||||
*
|
*
|
||||||
* @see FullScreenAdapter
|
* @see FullScreenAdapter
|
||||||
* @see GestureUtilities
|
* @see GestureUtilities
|
||||||
* @see com.sun.awt.AWTUtilities
|
|
||||||
*
|
*
|
||||||
* @since Java for Mac OS X 10.7 Update 1
|
* @since Java for Mac OS X 10.7 Update 1
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -25,13 +25,15 @@
|
||||||
|
|
||||||
package com.apple.eawt.event;
|
package com.apple.eawt.event;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JRootPane;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registration utility class to add {@link GestureListener}s to Swing components.
|
* Registration utility class to add {@link GestureListener}s to Swing components.
|
||||||
*
|
*
|
||||||
* This class manages the relationship between {@link JComponent}s and the {@link GestureListener}s
|
* This class manages the relationship between {@link JComponent}s and the {@link GestureListener}s
|
||||||
* attached to them. It's design is similar to the Java SE 6u10 {@link com.sun.awt.AWTUtilities}
|
* attached to them. It's design is similar to the Java SE 6u10 {@code com.sun.awt.AWTUtilities}
|
||||||
* class which adds additional functionality to AWT Windows, without adding new API to the
|
* class which adds additional functionality to AWT Windows, without adding new API to the
|
||||||
* {@link java.awt.Window} class.
|
* {@link java.awt.Window} class.
|
||||||
*
|
*
|
||||||
|
@ -40,7 +42,6 @@ import javax.swing.*;
|
||||||
*
|
*
|
||||||
* @see GestureAdapter
|
* @see GestureAdapter
|
||||||
* @see JFrame#getRootPane()
|
* @see JFrame#getRootPane()
|
||||||
* @see com.sun.awt.AWTUtilities
|
|
||||||
*
|
*
|
||||||
* @since Java for Mac OS X 10.5 Update 7, Java for Mac OS X 10.6 Update 2
|
* @since Java for Mac OS X 10.5 Update 7, Java for Mac OS X 10.6 Update 2
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -25,13 +25,25 @@
|
||||||
|
|
||||||
package sun.lwawt.macosx;
|
package sun.lwawt.macosx;
|
||||||
|
|
||||||
import com.apple.eawt.FullScreenAdapter;
|
import java.awt.Color;
|
||||||
import com.apple.eawt.FullScreenUtilities;
|
import java.awt.Component;
|
||||||
import com.apple.eawt.event.FullScreenEvent;
|
import java.awt.DefaultKeyboardFocusManager;
|
||||||
import java.awt.*;
|
import java.awt.Dialog;
|
||||||
import java.awt.Dialog.ModalityType;
|
import java.awt.Dialog.ModalityType;
|
||||||
import java.awt.event.*;
|
import java.awt.Font;
|
||||||
import java.beans.*;
|
import java.awt.FontMetrics;
|
||||||
|
import java.awt.Frame;
|
||||||
|
import java.awt.GraphicsDevice;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.MenuBar;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.Window;
|
||||||
|
import java.awt.event.FocusEvent;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.beans.PropertyChangeEvent;
|
||||||
|
import java.beans.PropertyChangeListener;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -39,20 +51,22 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.JRootPane;
|
||||||
|
import javax.swing.RootPaneContainer;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import sun.awt.*;
|
import com.apple.laf.ClientPropertyApplicator;
|
||||||
|
import com.apple.laf.ClientPropertyApplicator.Property;
|
||||||
|
import sun.awt.AWTAccessor;
|
||||||
import sun.awt.AWTAccessor.ComponentAccessor;
|
import sun.awt.AWTAccessor.ComponentAccessor;
|
||||||
import sun.awt.AWTAccessor.WindowAccessor;
|
import sun.awt.AWTAccessor.WindowAccessor;
|
||||||
import sun.java2d.SurfaceData;
|
import sun.java2d.SurfaceData;
|
||||||
import sun.java2d.opengl.CGLSurfaceData;
|
import sun.java2d.opengl.CGLSurfaceData;
|
||||||
import sun.lwawt.*;
|
import sun.lwawt.LWToolkit;
|
||||||
import sun.util.logging.PlatformLogger;
|
import sun.lwawt.LWWindowPeer;
|
||||||
|
|
||||||
import com.apple.laf.*;
|
|
||||||
import com.apple.laf.ClientPropertyApplicator.Property;
|
|
||||||
import com.sun.awt.AWTUtilities;
|
|
||||||
import sun.lwawt.LWWindowPeer.PeerType;
|
import sun.lwawt.LWWindowPeer.PeerType;
|
||||||
|
import sun.lwawt.PlatformWindow;
|
||||||
|
import sun.util.logging.PlatformLogger;
|
||||||
|
|
||||||
public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
|
public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
|
||||||
private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, long styleBits, double x, double y, double w, double h);
|
private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, long styleBits, double x, double y, double w, double h);
|
||||||
|
@ -172,7 +186,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||||
c.setStyleBits(TEXTURED, Boolean.parseBoolean(value.toString()));
|
c.setStyleBits(TEXTURED, Boolean.parseBoolean(value.toString()));
|
||||||
}},
|
}},
|
||||||
new Property<CPlatformWindow>(WINDOW_ALPHA) { public void applyProperty(final CPlatformWindow c, final Object value) {
|
new Property<CPlatformWindow>(WINDOW_ALPHA) { public void applyProperty(final CPlatformWindow c, final Object value) {
|
||||||
AWTUtilities.setWindowOpacity(c.target, value == null ? 1.0f : Float.parseFloat(value.toString()));
|
c.target.setOpacity(value == null ? 1.0f : Float.parseFloat(value.toString()));
|
||||||
}},
|
}},
|
||||||
new Property<CPlatformWindow>(WINDOW_SHADOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
|
new Property<CPlatformWindow>(WINDOW_SHADOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
|
||||||
c.setStyleBits(HAS_SHADOW, value == null ? true : Boolean.parseBoolean(value.toString()));
|
c.setStyleBits(HAS_SHADOW, value == null ? true : Boolean.parseBoolean(value.toString()));
|
||||||
|
|
|
@ -25,7 +25,16 @@
|
||||||
|
|
||||||
package com.sun.awt;
|
package com.sun.awt;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Dialog;
|
||||||
|
import java.awt.Frame;
|
||||||
|
import java.awt.GraphicsConfiguration;
|
||||||
|
import java.awt.GraphicsDevice;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.Shape;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.Window;
|
||||||
|
|
||||||
import javax.swing.JRootPane;
|
import javax.swing.JRootPane;
|
||||||
|
|
||||||
|
@ -64,6 +73,7 @@ import sun.awt.SunToolkit;
|
||||||
* drastically between update release, and it may even be
|
* drastically between update release, and it may even be
|
||||||
* removed or be moved in some other package(s)/class(es).
|
* removed or be moved in some other package(s)/class(es).
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "10")
|
||||||
public final class AWTUtilities {
|
public final class AWTUtilities {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,7 +124,10 @@ public final class AWTUtilities {
|
||||||
* (either PERPIXEL_TRANSPARENT,
|
* (either PERPIXEL_TRANSPARENT,
|
||||||
* TRANSLUCENT, or PERPIXEL_TRANSLUCENT)
|
* TRANSLUCENT, or PERPIXEL_TRANSLUCENT)
|
||||||
* @return whether the given translucency kind is supported
|
* @return whether the given translucency kind is supported
|
||||||
|
* @deprecated use {@link GraphicsDevice#isWindowTranslucencySupported}
|
||||||
|
* instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "10")
|
||||||
public static boolean isTranslucencySupported(Translucency translucencyKind) {
|
public static boolean isTranslucencySupported(Translucency translucencyKind) {
|
||||||
switch (translucencyKind) {
|
switch (translucencyKind) {
|
||||||
case PERPIXEL_TRANSPARENT:
|
case PERPIXEL_TRANSPARENT:
|
||||||
|
@ -166,14 +179,15 @@ public final class AWTUtilities {
|
||||||
* and the opacity is less than 1.0f
|
* and the opacity is less than 1.0f
|
||||||
* @throws UnsupportedOperationException if the TRANSLUCENT translucency
|
* @throws UnsupportedOperationException if the TRANSLUCENT translucency
|
||||||
* kind is not supported
|
* kind is not supported
|
||||||
|
* @deprecated use {@link Window#setOpacity} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "10")
|
||||||
public static void setWindowOpacity(Window window, float opacity) {
|
public static void setWindowOpacity(Window window, float opacity) {
|
||||||
if (window == null) {
|
if (window == null) {
|
||||||
throw new NullPointerException(
|
throw new NullPointerException(
|
||||||
"The window argument should not be null.");
|
"The window argument should not be null.");
|
||||||
}
|
}
|
||||||
|
window.setOpacity(opacity);
|
||||||
AWTAccessor.getWindowAccessor().setOpacity(window, opacity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,14 +196,16 @@ public final class AWTUtilities {
|
||||||
*
|
*
|
||||||
* @param window the window to get the opacity level from
|
* @param window the window to get the opacity level from
|
||||||
* @throws NullPointerException if the window argument is null
|
* @throws NullPointerException if the window argument is null
|
||||||
|
* @deprecated use {@link Window#getOpacity} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "10")
|
||||||
public static float getWindowOpacity(Window window) {
|
public static float getWindowOpacity(Window window) {
|
||||||
if (window == null) {
|
if (window == null) {
|
||||||
throw new NullPointerException(
|
throw new NullPointerException(
|
||||||
"The window argument should not be null.");
|
"The window argument should not be null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return AWTAccessor.getWindowAccessor().getOpacity(window);
|
return window.getOpacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -198,7 +214,10 @@ public final class AWTUtilities {
|
||||||
* Note that this method may sometimes return true, but the native
|
* Note that this method may sometimes return true, but the native
|
||||||
* windowing system may still not support the concept of
|
* windowing system may still not support the concept of
|
||||||
* shaping (due to the bugs in the windowing system).
|
* shaping (due to the bugs in the windowing system).
|
||||||
|
* @deprecated use {@link GraphicsDevice#isWindowTranslucencySupported}
|
||||||
|
* instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "10")
|
||||||
public static boolean isWindowShapingSupported() {
|
public static boolean isWindowShapingSupported() {
|
||||||
Toolkit curToolkit = Toolkit.getDefaultToolkit();
|
Toolkit curToolkit = Toolkit.getDefaultToolkit();
|
||||||
if (!(curToolkit instanceof SunToolkit)) {
|
if (!(curToolkit instanceof SunToolkit)) {
|
||||||
|
@ -216,13 +235,15 @@ public final class AWTUtilities {
|
||||||
* @param window the window to get the shape from
|
* @param window the window to get the shape from
|
||||||
* @return the current shape of the window
|
* @return the current shape of the window
|
||||||
* @throws NullPointerException if the window argument is null
|
* @throws NullPointerException if the window argument is null
|
||||||
|
* @deprecated use {@link Window#getShape} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "10")
|
||||||
public static Shape getWindowShape(Window window) {
|
public static Shape getWindowShape(Window window) {
|
||||||
if (window == null) {
|
if (window == null) {
|
||||||
throw new NullPointerException(
|
throw new NullPointerException(
|
||||||
"The window argument should not be null.");
|
"The window argument should not be null.");
|
||||||
}
|
}
|
||||||
return AWTAccessor.getWindowAccessor().getShape(window);
|
return window.getShape();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -247,13 +268,15 @@ public final class AWTUtilities {
|
||||||
* and the shape is not null
|
* and the shape is not null
|
||||||
* @throws UnsupportedOperationException if the PERPIXEL_TRANSPARENT
|
* @throws UnsupportedOperationException if the PERPIXEL_TRANSPARENT
|
||||||
* translucency kind is not supported
|
* translucency kind is not supported
|
||||||
|
* @deprecated use {@link Window#setShape} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "10")
|
||||||
public static void setWindowShape(Window window, Shape shape) {
|
public static void setWindowShape(Window window, Shape shape) {
|
||||||
if (window == null) {
|
if (window == null) {
|
||||||
throw new NullPointerException(
|
throw new NullPointerException(
|
||||||
"The window argument should not be null.");
|
"The window argument should not be null.");
|
||||||
}
|
}
|
||||||
AWTAccessor.getWindowAccessor().setShape(window, shape);
|
window.setShape(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isWindowTranslucencySupported() {
|
private static boolean isWindowTranslucencySupported() {
|
||||||
|
@ -349,7 +372,9 @@ public final class AWTUtilities {
|
||||||
* isOpaque argument is {@code false}.
|
* isOpaque argument is {@code false}.
|
||||||
* @throws UnsupportedOperationException if the PERPIXEL_TRANSLUCENT
|
* @throws UnsupportedOperationException if the PERPIXEL_TRANSLUCENT
|
||||||
* translucency kind is not supported
|
* translucency kind is not supported
|
||||||
|
* @deprecated use {@link Window#setBackground} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "10")
|
||||||
public static void setWindowOpaque(Window window, boolean isOpaque) {
|
public static void setWindowOpaque(Window window, boolean isOpaque) {
|
||||||
if (window == null) {
|
if (window == null) {
|
||||||
throw new NullPointerException(
|
throw new NullPointerException(
|
||||||
|
@ -359,7 +384,12 @@ public final class AWTUtilities {
|
||||||
throw new UnsupportedOperationException(
|
throw new UnsupportedOperationException(
|
||||||
"The PERPIXEL_TRANSLUCENT translucency kind is not supported");
|
"The PERPIXEL_TRANSLUCENT translucency kind is not supported");
|
||||||
}
|
}
|
||||||
AWTAccessor.getWindowAccessor().setOpaque(window, isOpaque);
|
Color bg = window.getBackground();
|
||||||
|
if (bg == null) {
|
||||||
|
bg = new Color(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
window.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue(),
|
||||||
|
isOpaque ? 255 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -369,7 +399,9 @@ public final class AWTUtilities {
|
||||||
* @return whether the window is currently opaque (true)
|
* @return whether the window is currently opaque (true)
|
||||||
* or translucent (false)
|
* or translucent (false)
|
||||||
* @throws NullPointerException if the window argument is null
|
* @throws NullPointerException if the window argument is null
|
||||||
|
* @deprecated use {@link Window#isOpaque} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "10")
|
||||||
public static boolean isWindowOpaque(Window window) {
|
public static boolean isWindowOpaque(Window window) {
|
||||||
if (window == null) {
|
if (window == null) {
|
||||||
throw new NullPointerException(
|
throw new NullPointerException(
|
||||||
|
@ -395,7 +427,10 @@ public final class AWTUtilities {
|
||||||
* @throws NullPointerException if the gc argument is null
|
* @throws NullPointerException if the gc argument is null
|
||||||
* @return whether the given GraphicsConfiguration supports
|
* @return whether the given GraphicsConfiguration supports
|
||||||
* the translucency effects.
|
* the translucency effects.
|
||||||
|
* @deprecated use {@link GraphicsConfiguration#isTranslucencyCapable}
|
||||||
|
* instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "10")
|
||||||
public static boolean isTranslucencyCapable(GraphicsConfiguration gc) {
|
public static boolean isTranslucencyCapable(GraphicsConfiguration gc) {
|
||||||
if (gc == null) {
|
if (gc == null) {
|
||||||
throw new NullPointerException("The gc argument should not be null");
|
throw new NullPointerException("The gc argument should not be null");
|
||||||
|
@ -448,8 +483,9 @@ public final class AWTUtilities {
|
||||||
* 'mixing-cutout' shape
|
* 'mixing-cutout' shape
|
||||||
* @param shape the new 'mixing-cutout' shape
|
* @param shape the new 'mixing-cutout' shape
|
||||||
* @throws NullPointerException if the component argument is {@code null}
|
* @throws NullPointerException if the component argument is {@code null}
|
||||||
|
* @deprecated use {@link Component#setMixingCutoutShape} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated(since = "9")
|
@Deprecated(forRemoval = true, since = "9")
|
||||||
public static void setComponentMixingCutoutShape(Component component,
|
public static void setComponentMixingCutoutShape(Component component,
|
||||||
Shape shape)
|
Shape shape)
|
||||||
{
|
{
|
||||||
|
|
|
@ -843,10 +843,6 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||||
public Rectangle getBounds(Component comp) {
|
public Rectangle getBounds(Component comp) {
|
||||||
return new Rectangle(comp.x, comp.y, comp.width, comp.height);
|
return new Rectangle(comp.x, comp.y, comp.width, comp.height);
|
||||||
}
|
}
|
||||||
public void setMixingCutoutShape(Component comp, Shape shape) {
|
|
||||||
comp.setMixingCutoutShape(shape);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGraphicsConfiguration(Component comp,
|
public void setGraphicsConfiguration(Component comp,
|
||||||
GraphicsConfiguration gc)
|
GraphicsConfiguration gc)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -23,12 +23,10 @@
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package java.awt;
|
package java.awt;
|
||||||
|
|
||||||
import java.awt.image.ColorModel;
|
import java.awt.image.ColorModel;
|
||||||
|
|
||||||
import sun.awt.AWTAccessor;
|
|
||||||
import sun.awt.AppContext;
|
import sun.awt.AppContext;
|
||||||
import sun.awt.SunToolkit;
|
import sun.awt.SunToolkit;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -22,9 +22,17 @@
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package java.awt;
|
package java.awt;
|
||||||
|
|
||||||
import java.awt.event.*;
|
import java.awt.event.ComponentEvent;
|
||||||
|
import java.awt.event.FocusEvent;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.MouseWheelEvent;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.awt.event.WindowFocusListener;
|
||||||
|
import java.awt.event.WindowListener;
|
||||||
|
import java.awt.event.WindowStateListener;
|
||||||
import java.awt.geom.Path2D;
|
import java.awt.geom.Path2D;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.im.InputContext;
|
import java.awt.im.InputContext;
|
||||||
|
@ -48,7 +56,13 @@ import java.util.ResourceBundle;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import javax.accessibility.*;
|
|
||||||
|
import javax.accessibility.Accessible;
|
||||||
|
import javax.accessibility.AccessibleContext;
|
||||||
|
import javax.accessibility.AccessibleRole;
|
||||||
|
import javax.accessibility.AccessibleState;
|
||||||
|
import javax.accessibility.AccessibleStateSet;
|
||||||
|
|
||||||
import sun.awt.AWTAccessor;
|
import sun.awt.AWTAccessor;
|
||||||
import sun.awt.AWTPermissions;
|
import sun.awt.AWTPermissions;
|
||||||
import sun.awt.AppContext;
|
import sun.awt.AppContext;
|
||||||
|
@ -4050,26 +4064,6 @@ public class Window extends Container implements Accessible {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
AWTAccessor.setWindowAccessor(new AWTAccessor.WindowAccessor() {
|
AWTAccessor.setWindowAccessor(new AWTAccessor.WindowAccessor() {
|
||||||
public float getOpacity(Window window) {
|
|
||||||
return window.opacity;
|
|
||||||
}
|
|
||||||
public void setOpacity(Window window, float opacity) {
|
|
||||||
window.setOpacity(opacity);
|
|
||||||
}
|
|
||||||
public Shape getShape(Window window) {
|
|
||||||
return window.getShape();
|
|
||||||
}
|
|
||||||
public void setShape(Window window, Shape shape) {
|
|
||||||
window.setShape(shape);
|
|
||||||
}
|
|
||||||
public void setOpaque(Window window, boolean opaque) {
|
|
||||||
Color bg = window.getBackground();
|
|
||||||
if (bg == null) {
|
|
||||||
bg = new Color(0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
window.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue(),
|
|
||||||
opaque ? 255 : 0));
|
|
||||||
}
|
|
||||||
public void updateWindow(Window window) {
|
public void updateWindow(Window window) {
|
||||||
window.updateWindow();
|
window.updateWindow();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -23,16 +23,22 @@
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package javax.swing;
|
package javax.swing;
|
||||||
|
|
||||||
import com.sun.awt.AWTUtilities;
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Container;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.Window;
|
||||||
|
import java.beans.PropertyVetoException;
|
||||||
|
|
||||||
import sun.awt.AWTAccessor;
|
import sun.awt.AWTAccessor;
|
||||||
import sun.awt.SunToolkit;
|
import sun.awt.SunToolkit;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.beans.PropertyVetoException;
|
|
||||||
|
|
||||||
/** This is an implementation of the <code>DesktopManager</code>.
|
/** This is an implementation of the <code>DesktopManager</code>.
|
||||||
* It currently implements the basic behaviors for managing
|
* It currently implements the basic behaviors for managing
|
||||||
* <code>JInternalFrame</code>s in an arbitrary parent.
|
* <code>JInternalFrame</code>s in an arbitrary parent.
|
||||||
|
@ -315,7 +321,7 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
String mode = (String)p.getClientProperty("JDesktopPane.dragMode");
|
String mode = (String)p.getClientProperty("JDesktopPane.dragMode");
|
||||||
Window window = SwingUtilities.getWindowAncestor(f);
|
Window window = SwingUtilities.getWindowAncestor(f);
|
||||||
if (window != null && !AWTUtilities.isWindowOpaque(window)) {
|
if (window != null && !window.isOpaque()) {
|
||||||
dragMode = DEFAULT_DRAG_MODE;
|
dragMode = DEFAULT_DRAG_MODE;
|
||||||
} else if (mode != null && mode.equals("outline")) {
|
} else if (mode != null && mode.equals("outline")) {
|
||||||
dragMode = OUTLINE_DRAG_MODE;
|
dragMode = OUTLINE_DRAG_MODE;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -290,26 +290,6 @@ public final class AWTAccessor {
|
||||||
* An interface of accessor for java.awt.Window class.
|
* An interface of accessor for java.awt.Window class.
|
||||||
*/
|
*/
|
||||||
public interface WindowAccessor {
|
public interface WindowAccessor {
|
||||||
/*
|
|
||||||
* Get opacity level of the given window.
|
|
||||||
*/
|
|
||||||
float getOpacity(Window window);
|
|
||||||
/*
|
|
||||||
* Set opacity level to the given window.
|
|
||||||
*/
|
|
||||||
void setOpacity(Window window, float opacity);
|
|
||||||
/*
|
|
||||||
* Get a shape assigned to the given window.
|
|
||||||
*/
|
|
||||||
Shape getShape(Window window);
|
|
||||||
/*
|
|
||||||
* Set a shape to the given window.
|
|
||||||
*/
|
|
||||||
void setShape(Window window, Shape shape);
|
|
||||||
/*
|
|
||||||
* Set the opaque preoperty to the given window.
|
|
||||||
*/
|
|
||||||
void setOpaque(Window window, boolean isOpaque);
|
|
||||||
/*
|
/*
|
||||||
* Update the image of a non-opaque (translucent) window.
|
* Update the image of a non-opaque (translucent) window.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -22,41 +22,135 @@
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sun.awt.X11;
|
package sun.awt.X11;
|
||||||
|
|
||||||
import java.awt.peer.TaskbarPeer;
|
import java.awt.AWTError;
|
||||||
import java.awt.*;
|
import java.awt.AWTException;
|
||||||
import java.awt.event.InputEvent;
|
import java.awt.Button;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.Canvas;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.Checkbox;
|
||||||
|
import java.awt.CheckboxMenuItem;
|
||||||
|
import java.awt.Choice;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Cursor;
|
||||||
|
import java.awt.Desktop;
|
||||||
|
import java.awt.Dialog;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
import java.awt.FileDialog;
|
||||||
|
import java.awt.Frame;
|
||||||
|
import java.awt.GraphicsConfiguration;
|
||||||
|
import java.awt.GraphicsDevice;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.HeadlessException;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.JobAttributes;
|
||||||
|
import java.awt.Label;
|
||||||
|
import java.awt.Menu;
|
||||||
|
import java.awt.MenuBar;
|
||||||
|
import java.awt.MenuItem;
|
||||||
|
import java.awt.PageAttributes;
|
||||||
|
import java.awt.Panel;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.PopupMenu;
|
||||||
|
import java.awt.PrintJob;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Robot;
|
||||||
|
import java.awt.ScrollPane;
|
||||||
|
import java.awt.Scrollbar;
|
||||||
|
import java.awt.SystemColor;
|
||||||
|
import java.awt.SystemTray;
|
||||||
|
import java.awt.Taskbar;
|
||||||
|
import java.awt.TextArea;
|
||||||
|
import java.awt.TextField;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.TrayIcon;
|
||||||
|
import java.awt.Window;
|
||||||
import java.awt.datatransfer.Clipboard;
|
import java.awt.datatransfer.Clipboard;
|
||||||
import java.awt.dnd.DragSource;
|
|
||||||
import java.awt.dnd.DragGestureListener;
|
|
||||||
import java.awt.dnd.DragGestureEvent;
|
import java.awt.dnd.DragGestureEvent;
|
||||||
|
import java.awt.dnd.DragGestureListener;
|
||||||
import java.awt.dnd.DragGestureRecognizer;
|
import java.awt.dnd.DragGestureRecognizer;
|
||||||
import java.awt.dnd.MouseDragGestureRecognizer;
|
import java.awt.dnd.DragSource;
|
||||||
import java.awt.dnd.InvalidDnDOperationException;
|
import java.awt.dnd.InvalidDnDOperationException;
|
||||||
|
import java.awt.dnd.MouseDragGestureRecognizer;
|
||||||
import java.awt.dnd.peer.DragSourceContextPeer;
|
import java.awt.dnd.peer.DragSourceContextPeer;
|
||||||
|
import java.awt.event.InputEvent;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.font.TextAttribute;
|
import java.awt.font.TextAttribute;
|
||||||
import java.awt.im.InputMethodHighlight;
|
import java.awt.im.InputMethodHighlight;
|
||||||
import java.awt.im.spi.InputMethodDescriptor;
|
import java.awt.im.spi.InputMethodDescriptor;
|
||||||
import java.awt.peer.*;
|
import java.awt.peer.ButtonPeer;
|
||||||
|
import java.awt.peer.CanvasPeer;
|
||||||
|
import java.awt.peer.CheckboxMenuItemPeer;
|
||||||
|
import java.awt.peer.CheckboxPeer;
|
||||||
|
import java.awt.peer.ChoicePeer;
|
||||||
|
import java.awt.peer.DesktopPeer;
|
||||||
|
import java.awt.peer.DialogPeer;
|
||||||
|
import java.awt.peer.FileDialogPeer;
|
||||||
|
import java.awt.peer.FontPeer;
|
||||||
|
import java.awt.peer.FramePeer;
|
||||||
|
import java.awt.peer.KeyboardFocusManagerPeer;
|
||||||
|
import java.awt.peer.LabelPeer;
|
||||||
|
import java.awt.peer.ListPeer;
|
||||||
|
import java.awt.peer.MenuBarPeer;
|
||||||
|
import java.awt.peer.MenuItemPeer;
|
||||||
|
import java.awt.peer.MenuPeer;
|
||||||
|
import java.awt.peer.MouseInfoPeer;
|
||||||
|
import java.awt.peer.PanelPeer;
|
||||||
|
import java.awt.peer.PopupMenuPeer;
|
||||||
|
import java.awt.peer.RobotPeer;
|
||||||
|
import java.awt.peer.ScrollPanePeer;
|
||||||
|
import java.awt.peer.ScrollbarPeer;
|
||||||
|
import java.awt.peer.SystemTrayPeer;
|
||||||
|
import java.awt.peer.TaskbarPeer;
|
||||||
|
import java.awt.peer.TextAreaPeer;
|
||||||
|
import java.awt.peer.TextFieldPeer;
|
||||||
|
import java.awt.peer.TrayIconPeer;
|
||||||
|
import java.awt.peer.WindowPeer;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.SortedMap;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
import javax.swing.LookAndFeel;
|
import javax.swing.LookAndFeel;
|
||||||
import javax.swing.UIDefaults;
|
import javax.swing.UIDefaults;
|
||||||
import sun.awt.*;
|
|
||||||
|
import sun.awt.AWTAccessor;
|
||||||
|
import sun.awt.AWTPermissions;
|
||||||
|
import sun.awt.AppContext;
|
||||||
|
import sun.awt.DisplayChangedListener;
|
||||||
|
import sun.awt.LightweightFrame;
|
||||||
|
import sun.awt.SunToolkit;
|
||||||
|
import sun.awt.UNIXToolkit;
|
||||||
|
import sun.awt.X11GraphicsConfig;
|
||||||
|
import sun.awt.X11GraphicsDevice;
|
||||||
|
import sun.awt.X11GraphicsEnvironment;
|
||||||
|
import sun.awt.XSettings;
|
||||||
import sun.awt.datatransfer.DataTransferer;
|
import sun.awt.datatransfer.DataTransferer;
|
||||||
import sun.font.FontConfigManager;
|
|
||||||
import sun.java2d.SunGraphicsEnvironment;
|
|
||||||
import sun.awt.util.PerformanceLogger;
|
import sun.awt.util.PerformanceLogger;
|
||||||
import sun.awt.util.ThreadGroupUtils;
|
import sun.awt.util.ThreadGroupUtils;
|
||||||
|
import sun.font.FontConfigManager;
|
||||||
|
import sun.java2d.SunGraphicsEnvironment;
|
||||||
import sun.print.PrintJob2D;
|
import sun.print.PrintJob2D;
|
||||||
import sun.security.action.GetPropertyAction;
|
|
||||||
import sun.security.action.GetBooleanAction;
|
import sun.security.action.GetBooleanAction;
|
||||||
|
import sun.security.action.GetPropertyAction;
|
||||||
import sun.util.logging.PlatformLogger;
|
import sun.util.logging.PlatformLogger;
|
||||||
|
|
||||||
import static sun.awt.X11.XlibUtil.scaleDown;
|
import static sun.awt.X11.XlibUtil.scaleDown;
|
||||||
|
|
||||||
public final class XToolkit extends UNIXToolkit implements Runnable {
|
public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||||
|
@ -2587,7 +2681,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
public boolean isWindowTranslucencySupported() {
|
public boolean isWindowTranslucencySupported() {
|
||||||
//NOTE: it may not be supported. The actual check is being performed
|
//NOTE: it may not be supported. The actual check is being performed
|
||||||
// at com.sun.awt.AWTUtilities(). In X11 we need to check
|
// at java.awt.GraphicsDevice. In X11 we need to check
|
||||||
// whether there's any translucency-capable GC available.
|
// whether there's any translucency-capable GC available.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -22,42 +22,50 @@
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sun.awt.X11;
|
package sun.awt.X11;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.AWTEvent;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Dialog;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
import java.awt.Frame;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.GraphicsConfiguration;
|
||||||
|
import java.awt.GraphicsDevice;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Shape;
|
||||||
|
import java.awt.SystemColor;
|
||||||
|
import java.awt.Window;
|
||||||
import java.awt.event.ComponentEvent;
|
import java.awt.event.ComponentEvent;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.awt.geom.AffineTransform;
|
|
||||||
|
|
||||||
import java.awt.peer.ComponentPeer;
|
import java.awt.peer.ComponentPeer;
|
||||||
import java.awt.peer.WindowPeer;
|
import java.awt.peer.WindowPeer;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import sun.awt.AWTAccessor.ComponentAccessor;
|
|
||||||
import sun.util.logging.PlatformLogger;
|
|
||||||
|
|
||||||
import sun.awt.AWTAccessor;
|
import sun.awt.AWTAccessor;
|
||||||
|
import sun.awt.AWTAccessor.ComponentAccessor;
|
||||||
import sun.awt.DisplayChangedListener;
|
import sun.awt.DisplayChangedListener;
|
||||||
|
import sun.awt.IconInfo;
|
||||||
import sun.awt.SunToolkit;
|
import sun.awt.SunToolkit;
|
||||||
import sun.awt.X11GraphicsDevice;
|
import sun.awt.X11GraphicsDevice;
|
||||||
import sun.awt.X11GraphicsEnvironment;
|
import sun.awt.X11GraphicsEnvironment;
|
||||||
import sun.awt.IconInfo;
|
|
||||||
|
|
||||||
import sun.java2d.pipe.Region;
|
import sun.java2d.pipe.Region;
|
||||||
|
import sun.util.logging.PlatformLogger;
|
||||||
|
|
||||||
class XWindowPeer extends XPanelPeer implements WindowPeer,
|
class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||||
DisplayChangedListener {
|
DisplayChangedListener {
|
||||||
|
@ -446,16 +454,14 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateShape() {
|
private void updateShape() {
|
||||||
// Shape shape = ((Window)target).getShape();
|
Shape shape = ((Window)target).getShape();
|
||||||
Shape shape = AWTAccessor.getWindowAccessor().getShape((Window)target);
|
|
||||||
if (shape != null) {
|
if (shape != null) {
|
||||||
applyShape(Region.getInstance(shape, null));
|
applyShape(Region.getInstance(shape, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateOpacity() {
|
private void updateOpacity() {
|
||||||
// float opacity = ((Window)target).getOpacity();
|
float opacity = ((Window)target).getOpacity();
|
||||||
float opacity = AWTAccessor.getWindowAccessor().getOpacity((Window)target);
|
|
||||||
if (opacity < 1.0f) {
|
if (opacity < 1.0f) {
|
||||||
setOpacity(opacity);
|
setOpacity(opacity);
|
||||||
}
|
}
|
||||||
|
@ -2375,7 +2381,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||||
public void print(Graphics g) {
|
public void print(Graphics g) {
|
||||||
// We assume we print the whole frame,
|
// We assume we print the whole frame,
|
||||||
// so we expect no clip was set previously
|
// so we expect no clip was set previously
|
||||||
Shape shape = AWTAccessor.getWindowAccessor().getShape((Window)target);
|
Shape shape = ((Window)target).getShape();
|
||||||
if (shape != null) {
|
if (shape != null) {
|
||||||
g.setClip(shape);
|
g.setClip(shape);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -22,23 +22,48 @@
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package sun.awt.windows;
|
package sun.awt.windows;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.AWTEvent;
|
||||||
import java.awt.event.*;
|
import java.awt.AWTEventMulticaster;
|
||||||
import java.awt.image.*;
|
import java.awt.Color;
|
||||||
import java.awt.peer.*;
|
import java.awt.Component;
|
||||||
|
import java.awt.Container;
|
||||||
import java.beans.*;
|
import java.awt.Dialog;
|
||||||
|
import java.awt.Dimension;
|
||||||
import java.util.*;
|
import java.awt.Graphics;
|
||||||
import java.util.List;
|
import java.awt.GraphicsConfiguration;
|
||||||
import sun.util.logging.PlatformLogger;
|
import java.awt.GraphicsDevice;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.KeyboardFocusManager;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Shape;
|
||||||
|
import java.awt.SystemColor;
|
||||||
|
import java.awt.Window;
|
||||||
|
import java.awt.event.FocusEvent;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.awt.event.WindowListener;
|
||||||
import java.awt.geom.AffineTransform;
|
import java.awt.geom.AffineTransform;
|
||||||
import sun.awt.*;
|
import java.awt.image.DataBufferInt;
|
||||||
|
import java.awt.peer.WindowPeer;
|
||||||
|
import java.beans.PropertyChangeEvent;
|
||||||
|
import java.beans.PropertyChangeListener;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import sun.awt.AWTAccessor;
|
||||||
|
import sun.awt.AppContext;
|
||||||
|
import sun.awt.DisplayChangedListener;
|
||||||
|
import sun.awt.SunToolkit;
|
||||||
|
import sun.awt.Win32GraphicsConfig;
|
||||||
|
import sun.awt.Win32GraphicsDevice;
|
||||||
|
import sun.awt.Win32GraphicsEnvironment;
|
||||||
import sun.java2d.pipe.Region;
|
import sun.java2d.pipe.Region;
|
||||||
import sun.swing.SwingUtilities2;
|
import sun.swing.SwingUtilities2;
|
||||||
|
import sun.util.logging.PlatformLogger;
|
||||||
|
|
||||||
public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||||
DisplayChangedListener
|
DisplayChangedListener
|
||||||
|
@ -671,7 +696,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||||
public void print(Graphics g) {
|
public void print(Graphics g) {
|
||||||
// We assume we print the whole frame,
|
// We assume we print the whole frame,
|
||||||
// so we expect no clip was set previously
|
// so we expect no clip was set previously
|
||||||
Shape shape = AWTAccessor.getWindowAccessor().getShape((Window)target);
|
Shape shape = ((Window)target).getShape();
|
||||||
if (shape != null) {
|
if (shape != null) {
|
||||||
g.setClip(shape);
|
g.setClip(shape);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,467 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
|
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
@test %W% %E%
|
|
||||||
@key headful
|
|
||||||
@bug 6594131
|
|
||||||
@summary Tests the AWTUtilities.get/setWindowOpacity() methods
|
|
||||||
@author anthony.petrov@...: area=awt.toplevel
|
|
||||||
@modules java.desktop/com.sun.awt
|
|
||||||
@run main WindowOpacity
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.*;
|
|
||||||
|
|
||||||
import com.sun.awt.AWTUtilities;
|
|
||||||
|
|
||||||
public class WindowOpacity
|
|
||||||
{
|
|
||||||
//*** test-writer defined static variables go here ***
|
|
||||||
|
|
||||||
private static Robot robot;
|
|
||||||
|
|
||||||
|
|
||||||
private static void init()
|
|
||||||
{
|
|
||||||
//*** Create instructions for the user here ***
|
|
||||||
String[] instructions =
|
|
||||||
{
|
|
||||||
"This is an AUTOMATIC test, simply wait until it is done.",
|
|
||||||
"The result (passed or failed) will be shown in the",
|
|
||||||
"message window below."
|
|
||||||
};
|
|
||||||
Sysout.createDialog( );
|
|
||||||
Sysout.printInstructions( instructions );
|
|
||||||
|
|
||||||
if (!AWTUtilities.isTranslucencySupported(AWTUtilities.Translucency.TRANSLUCENT)) {
|
|
||||||
System.out.println("Either the Toolkit or the native system does not support controlling the window opacity level.");
|
|
||||||
pass();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
robot = new Robot();
|
|
||||||
}catch(Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
throw new RuntimeException ("Unexpected failure");
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean passed;
|
|
||||||
|
|
||||||
Frame f = new Frame("Opacity test");
|
|
||||||
f.setUndecorated(true);
|
|
||||||
|
|
||||||
passed = false;
|
|
||||||
try {
|
|
||||||
AWTUtilities.getWindowOpacity(null);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
passed = true;
|
|
||||||
}
|
|
||||||
if (!passed) {
|
|
||||||
fail("getWindowOpacity() allows passing null.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
passed = false;
|
|
||||||
try {
|
|
||||||
AWTUtilities.setWindowOpacity(null, 0.5f);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
passed = true;
|
|
||||||
}
|
|
||||||
if (!passed) {
|
|
||||||
fail("setWindowOpacity() allows passing null.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
float curOpacity = AWTUtilities.getWindowOpacity(f);
|
|
||||||
if (curOpacity < 1.0f || curOpacity > 1.0f) {
|
|
||||||
fail("getWindowOpacity() reports the initial opacity level other than 1.0: " + curOpacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
passed = false;
|
|
||||||
try {
|
|
||||||
AWTUtilities.setWindowOpacity(f, -0.5f);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
passed = true;
|
|
||||||
}
|
|
||||||
if (!passed) {
|
|
||||||
fail("setWindowOpacity() allows passing negative opacity level.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
passed = false;
|
|
||||||
try {
|
|
||||||
AWTUtilities.setWindowOpacity(f, 1.5f);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
passed = true;
|
|
||||||
}
|
|
||||||
if (!passed) {
|
|
||||||
fail("setWindowOpacity() allows passing opacity level greater than 1.0.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AWTUtilities.setWindowOpacity(f, 0.5f);
|
|
||||||
|
|
||||||
curOpacity = AWTUtilities.getWindowOpacity(f);
|
|
||||||
if (curOpacity < 0.5f || curOpacity > 0.5f) {
|
|
||||||
fail("getWindowOpacity() reports the opacity level that differs from the value set with setWindowOpacity: " + curOpacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AWTUtilities.setWindowOpacity(f, 0.75f);
|
|
||||||
|
|
||||||
curOpacity = AWTUtilities.getWindowOpacity(f);
|
|
||||||
if (curOpacity < 0.75f || curOpacity > 0.75f) {
|
|
||||||
fail("getWindowOpacity() reports the opacity level that differs from the value set with setWindowOpacity the second time: " + curOpacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
f.setBounds(100, 100, 300, 200);
|
|
||||||
f.setVisible(true);
|
|
||||||
|
|
||||||
robot.waitForIdle();
|
|
||||||
|
|
||||||
curOpacity = AWTUtilities.getWindowOpacity(f);
|
|
||||||
if (curOpacity < 0.75f || curOpacity > 0.75f) {
|
|
||||||
fail("getWindowOpacity() reports the opacity level that differs from the value set with setWindowOpacity before showing the frame: " + curOpacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AWTUtilities.setWindowOpacity(f, 0.5f);
|
|
||||||
robot.waitForIdle();
|
|
||||||
|
|
||||||
curOpacity = AWTUtilities.getWindowOpacity(f);
|
|
||||||
if (curOpacity < 0.5f || curOpacity > 0.5f) {
|
|
||||||
fail("getWindowOpacity() reports the opacity level that differs from the value set with setWindowOpacity after showing the frame: " + curOpacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowOpacity.pass();
|
|
||||||
|
|
||||||
}//End init()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************
|
|
||||||
* Standard Test Machinery Section
|
|
||||||
* DO NOT modify anything in this section -- it's a
|
|
||||||
* standard chunk of code which has all of the
|
|
||||||
* synchronisation necessary for the test harness.
|
|
||||||
* By keeping it the same in all tests, it is easier
|
|
||||||
* to read and understand someone else's test, as
|
|
||||||
* well as insuring that all tests behave correctly
|
|
||||||
* with the test harness.
|
|
||||||
* There is a section following this for test-
|
|
||||||
* classes
|
|
||||||
******************************************************/
|
|
||||||
private static boolean theTestPassed = false;
|
|
||||||
private static boolean testGeneratedInterrupt = false;
|
|
||||||
private static String failureMessage = "";
|
|
||||||
|
|
||||||
private static Thread mainThread = null;
|
|
||||||
|
|
||||||
private static int sleepTime = 300000;
|
|
||||||
|
|
||||||
// Not sure about what happens if multiple of this test are
|
|
||||||
// instantiated in the same VM. Being static (and using
|
|
||||||
// static vars), it aint gonna work. Not worrying about
|
|
||||||
// it for now.
|
|
||||||
public static void main( String args[] ) throws InterruptedException
|
|
||||||
{
|
|
||||||
mainThread = Thread.currentThread();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
catch( TestPassedException e )
|
|
||||||
{
|
|
||||||
//The test passed, so just return from main and harness will
|
|
||||||
// interepret this return as a pass
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//At this point, neither test pass nor test fail has been
|
|
||||||
// called -- either would have thrown an exception and ended the
|
|
||||||
// test, so we know we have multiple threads.
|
|
||||||
|
|
||||||
//Test involves other threads, so sleep and wait for them to
|
|
||||||
// called pass() or fail()
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Thread.sleep( sleepTime );
|
|
||||||
//Timed out, so fail the test
|
|
||||||
throw new RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
|
|
||||||
}
|
|
||||||
catch (InterruptedException e)
|
|
||||||
{
|
|
||||||
//The test harness may have interrupted the test. If so, rethrow the exception
|
|
||||||
// so that the harness gets it and deals with it.
|
|
||||||
if( ! testGeneratedInterrupt ) throw e;
|
|
||||||
|
|
||||||
//reset flag in case hit this code more than once for some reason (just safety)
|
|
||||||
testGeneratedInterrupt = false;
|
|
||||||
|
|
||||||
if ( theTestPassed == false )
|
|
||||||
{
|
|
||||||
throw new RuntimeException( failureMessage );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}//main
|
|
||||||
|
|
||||||
public static synchronized void setTimeoutTo( int seconds )
|
|
||||||
{
|
|
||||||
sleepTime = seconds * 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void pass()
|
|
||||||
{
|
|
||||||
Sysout.println( "The test passed." );
|
|
||||||
Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
|
|
||||||
//first check if this is executing in main thread
|
|
||||||
if ( mainThread == Thread.currentThread() )
|
|
||||||
{
|
|
||||||
//Still in the main thread, so set the flag just for kicks,
|
|
||||||
// and throw a test passed exception which will be caught
|
|
||||||
// and end the test.
|
|
||||||
theTestPassed = true;
|
|
||||||
throw new TestPassedException();
|
|
||||||
}
|
|
||||||
theTestPassed = true;
|
|
||||||
testGeneratedInterrupt = true;
|
|
||||||
mainThread.interrupt();
|
|
||||||
}//pass()
|
|
||||||
|
|
||||||
public static synchronized void fail()
|
|
||||||
{
|
|
||||||
//test writer didn't specify why test failed, so give generic
|
|
||||||
fail( "it just plain failed! :-)" );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void fail( String whyFailed )
|
|
||||||
{
|
|
||||||
Sysout.println( "The test failed: " + whyFailed );
|
|
||||||
Sysout.println( "The test is over, hit Ctl-C to stop Java VM" );
|
|
||||||
//check if this called from main thread
|
|
||||||
if ( mainThread == Thread.currentThread() )
|
|
||||||
{
|
|
||||||
//If main thread, fail now 'cause not sleeping
|
|
||||||
throw new RuntimeException( whyFailed );
|
|
||||||
}
|
|
||||||
theTestPassed = false;
|
|
||||||
testGeneratedInterrupt = true;
|
|
||||||
failureMessage = whyFailed;
|
|
||||||
mainThread.interrupt();
|
|
||||||
}//fail()
|
|
||||||
|
|
||||||
}// class WindowOpacity
|
|
||||||
|
|
||||||
//This exception is used to exit from any level of call nesting
|
|
||||||
// when it's determined that the test has passed, and immediately
|
|
||||||
// end the test.
|
|
||||||
class TestPassedException extends RuntimeException
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//*********** End Standard Test Machinery Section **********
|
|
||||||
|
|
||||||
|
|
||||||
//************ Begin classes defined for the test ****************
|
|
||||||
|
|
||||||
// if want to make listeners, here is the recommended place for them, then instantiate
|
|
||||||
// them in init()
|
|
||||||
|
|
||||||
/* Example of a class which may be written as part of a test
|
|
||||||
class NewClass implements anInterface
|
|
||||||
{
|
|
||||||
static int newVar = 0;
|
|
||||||
|
|
||||||
public void eventDispatched(AWTEvent e)
|
|
||||||
{
|
|
||||||
//Counting events to see if we get enough
|
|
||||||
eventCount++;
|
|
||||||
|
|
||||||
if( eventCount == 20 )
|
|
||||||
{
|
|
||||||
//got enough events, so pass
|
|
||||||
|
|
||||||
WindowOpacity.pass();
|
|
||||||
}
|
|
||||||
else if( tries == 20 )
|
|
||||||
{
|
|
||||||
//tried too many times without getting enough events so fail
|
|
||||||
|
|
||||||
WindowOpacity.fail();
|
|
||||||
}
|
|
||||||
|
|
||||||
}// eventDispatched()
|
|
||||||
|
|
||||||
}// NewClass class
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//************** End classes defined for the test *******************
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************
|
|
||||||
Standard Test Machinery
|
|
||||||
DO NOT modify anything below -- it's a standard
|
|
||||||
chunk of code whose purpose is to make user
|
|
||||||
interaction uniform, and thereby make it simpler
|
|
||||||
to read and understand someone else's test.
|
|
||||||
****************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
This is part of the standard test machinery.
|
|
||||||
It creates a dialog (with the instructions), and is the interface
|
|
||||||
for sending text messages to the user.
|
|
||||||
To print the instructions, send an array of strings to Sysout.createDialog
|
|
||||||
WithInstructions method. Put one line of instructions per array entry.
|
|
||||||
To display a message for the tester to see, simply call Sysout.println
|
|
||||||
with the string to be displayed.
|
|
||||||
This mimics System.out.println but works within the test harness as well
|
|
||||||
as standalone.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Sysout
|
|
||||||
{
|
|
||||||
private static TestDialog dialog;
|
|
||||||
|
|
||||||
public static void createDialogWithInstructions( String[] instructions )
|
|
||||||
{
|
|
||||||
dialog = new TestDialog( new Frame(), "Instructions" );
|
|
||||||
dialog.printInstructions( instructions );
|
|
||||||
dialog.setVisible(true);
|
|
||||||
println( "Any messages for the tester will display here." );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void createDialog( )
|
|
||||||
{
|
|
||||||
dialog = new TestDialog( new Frame(), "Instructions" );
|
|
||||||
String[] defInstr = { "Instructions will appear here. ", "" } ;
|
|
||||||
dialog.printInstructions( defInstr );
|
|
||||||
dialog.setVisible(true);
|
|
||||||
println( "Any messages for the tester will display here." );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void printInstructions( String[] instructions )
|
|
||||||
{
|
|
||||||
dialog.printInstructions( instructions );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void println( String messageIn )
|
|
||||||
{
|
|
||||||
dialog.displayMessage( messageIn );
|
|
||||||
System.out.println(messageIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
}// Sysout class
|
|
||||||
|
|
||||||
/**
|
|
||||||
This is part of the standard test machinery. It provides a place for the
|
|
||||||
test instructions to be displayed, and a place for interactive messages
|
|
||||||
to the user to be displayed.
|
|
||||||
To have the test instructions displayed, see Sysout.
|
|
||||||
To have a message to the user be displayed, see Sysout.
|
|
||||||
Do not call anything in this dialog directly.
|
|
||||||
*/
|
|
||||||
class TestDialog extends Dialog
|
|
||||||
{
|
|
||||||
|
|
||||||
TextArea instructionsText;
|
|
||||||
TextArea messageText;
|
|
||||||
int maxStringLength = 80;
|
|
||||||
|
|
||||||
//DO NOT call this directly, go through Sysout
|
|
||||||
public TestDialog( Frame frame, String name )
|
|
||||||
{
|
|
||||||
super( frame, name );
|
|
||||||
int scrollBoth = TextArea.SCROLLBARS_BOTH;
|
|
||||||
instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
|
|
||||||
add( "North", instructionsText );
|
|
||||||
|
|
||||||
messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
|
|
||||||
add("Center", messageText);
|
|
||||||
|
|
||||||
pack();
|
|
||||||
|
|
||||||
setVisible(true);
|
|
||||||
}// TestDialog()
|
|
||||||
|
|
||||||
//DO NOT call this directly, go through Sysout
|
|
||||||
public void printInstructions( String[] instructions )
|
|
||||||
{
|
|
||||||
//Clear out any current instructions
|
|
||||||
instructionsText.setText( "" );
|
|
||||||
|
|
||||||
//Go down array of instruction strings
|
|
||||||
|
|
||||||
String printStr, remainingStr;
|
|
||||||
for( int i=0; i < instructions.length; i++ )
|
|
||||||
{
|
|
||||||
//chop up each into pieces maxSringLength long
|
|
||||||
remainingStr = instructions[ i ];
|
|
||||||
while( remainingStr.length() > 0 )
|
|
||||||
{
|
|
||||||
//if longer than max then chop off first max chars to print
|
|
||||||
if( remainingStr.length() >= maxStringLength )
|
|
||||||
{
|
|
||||||
//Try to chop on a word boundary
|
|
||||||
int posOfSpace = remainingStr.
|
|
||||||
lastIndexOf( ' ', maxStringLength - 1 );
|
|
||||||
|
|
||||||
if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
|
|
||||||
|
|
||||||
printStr = remainingStr.substring( 0, posOfSpace + 1 );
|
|
||||||
remainingStr = remainingStr.substring( posOfSpace + 1 );
|
|
||||||
}
|
|
||||||
//else just print
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printStr = remainingStr;
|
|
||||||
remainingStr = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
instructionsText.append( printStr + "\n" );
|
|
||||||
|
|
||||||
}// while
|
|
||||||
|
|
||||||
}// for
|
|
||||||
|
|
||||||
}//printInstructions()
|
|
||||||
|
|
||||||
//DO NOT call this directly, go through Sysout
|
|
||||||
public void displayMessage( String messageIn )
|
|
||||||
{
|
|
||||||
messageText.append( messageIn + "\n" );
|
|
||||||
System.out.println(messageIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
}// TestDialog class
|
|
|
@ -0,0 +1,139 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
@test
|
||||||
|
@key headful
|
||||||
|
@bug 6594131 8186617
|
||||||
|
@summary Tests the Window.get/setOpacity() methods
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.AWTException;
|
||||||
|
import java.awt.Frame;
|
||||||
|
import java.awt.GraphicsDevice;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.Robot;
|
||||||
|
|
||||||
|
public class WindowOpacity {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
GraphicsDevice gd =
|
||||||
|
GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||||
|
.getDefaultScreenDevice();
|
||||||
|
if (!gd.isWindowTranslucencySupported(
|
||||||
|
GraphicsDevice.WindowTranslucency.TRANSLUCENT)) {
|
||||||
|
System.out.println(
|
||||||
|
"Either the Toolkit or the native system does not support"
|
||||||
|
+ " controlling the window opacity level.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Frame f = new Frame("Opacity test");
|
||||||
|
try {
|
||||||
|
test(f);
|
||||||
|
} finally {
|
||||||
|
f.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void test(final Frame f) throws AWTException {
|
||||||
|
boolean passed;
|
||||||
|
|
||||||
|
f.setUndecorated(true);
|
||||||
|
float curOpacity = f.getOpacity();
|
||||||
|
if (curOpacity < 1.0f || curOpacity > 1.0f) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"getOpacity() reports the initial opacity level "
|
||||||
|
+ "other than 1.0: " + curOpacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
passed = false;
|
||||||
|
try {
|
||||||
|
f.setOpacity(-0.5f);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
passed = true;
|
||||||
|
}
|
||||||
|
if (!passed) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"setOpacity() allows passing negative opacity level.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
passed = false;
|
||||||
|
try {
|
||||||
|
f.setOpacity(1.5f);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
passed = true;
|
||||||
|
}
|
||||||
|
if (!passed) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"setOpacity() allows passing opacity level greater than 1.0.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
f.setOpacity(0.5f);
|
||||||
|
curOpacity = f.getOpacity();
|
||||||
|
if (curOpacity < 0.5f || curOpacity > 0.5f) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"setOpacity() reports the opacity level that "
|
||||||
|
+ "differs from the value set with "
|
||||||
|
+ "setWindowOpacity: " + curOpacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
f.setOpacity(0.75f);
|
||||||
|
curOpacity = f.getOpacity();
|
||||||
|
if (curOpacity < 0.75f || curOpacity > 0.75f) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"getOpacity() reports the opacity level that "
|
||||||
|
+ "differs from the value set with "
|
||||||
|
+ "setWindowOpacity the second time: "
|
||||||
|
+ curOpacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
f.setBounds(100, 100, 300, 200);
|
||||||
|
f.setVisible(true);
|
||||||
|
Robot robot = new Robot();
|
||||||
|
robot.waitForIdle();
|
||||||
|
|
||||||
|
curOpacity = f.getOpacity();
|
||||||
|
if (curOpacity < 0.75f || curOpacity > 0.75f) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"getOpacity() reports the opacity level that "
|
||||||
|
+ "differs from the value set with "
|
||||||
|
+ "setWindowOpacity before showing the frame: "
|
||||||
|
+ curOpacity);
|
||||||
|
}
|
||||||
|
f.setOpacity(0.5f);
|
||||||
|
robot.waitForIdle();
|
||||||
|
curOpacity = f.getOpacity();
|
||||||
|
if (curOpacity < 0.5f || curOpacity > 0.5f) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"getOpacity() reports the opacity level that "
|
||||||
|
+ "differs from the value set with "
|
||||||
|
+ "setWindowOpacity after showing the frame: "
|
||||||
|
+ curOpacity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -24,29 +24,32 @@
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @key headful
|
* @key headful
|
||||||
* @bug 6683775 6794764
|
* @bug 6683775 6794764 8186617
|
||||||
* @summary Painting artifacts is seen when panel is made setOpaque(false) for a translucent window
|
* @summary Painting artifacts is seen when panel is made setOpaque(false) for a
|
||||||
* @author Alexander Potochkin
|
* translucent window
|
||||||
* @modules java.desktop/com.sun.awt
|
|
||||||
* java.desktop/sun.awt
|
|
||||||
* @run main bug6683775
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.sun.awt.AWTUtilities;
|
import java.awt.Color;
|
||||||
|
import java.awt.GraphicsConfiguration;
|
||||||
import javax.swing.*;
|
import java.awt.GraphicsDevice;
|
||||||
import java.awt.*;
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Robot;
|
||||||
|
import java.awt.Window;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
public class bug6683775 {
|
public class bug6683775 {
|
||||||
static final int LOC = 100,
|
static final int LOC = 100,
|
||||||
SIZE = 200;
|
SIZE = 200;
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
GraphicsConfiguration gc = getGC();
|
GraphicsConfiguration gc = getGC();
|
||||||
if (!AWTUtilities.isTranslucencySupported(
|
if (gc == null || !gc.getDevice().isWindowTranslucencySupported(
|
||||||
AWTUtilities.Translucency.PERPIXEL_TRANSLUCENT)
|
GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
|
||||||
|| gc == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Robot robot = new Robot();
|
Robot robot = new Robot();
|
||||||
|
@ -65,7 +68,7 @@ public class bug6683775 {
|
||||||
JPanel p = new JPanel();
|
JPanel p = new JPanel();
|
||||||
p.setOpaque(false);
|
p.setOpaque(false);
|
||||||
testFrame.add(p);
|
testFrame.add(p);
|
||||||
AWTUtilities.setWindowOpaque(testFrame, false);
|
setOpaque(testFrame, false);
|
||||||
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
testFrame.setBounds(LOC, LOC, SIZE, SIZE);
|
testFrame.setBounds(LOC, LOC, SIZE, SIZE);
|
||||||
testFrame.setVisible(true);
|
testFrame.setVisible(true);
|
||||||
|
@ -78,17 +81,28 @@ public class bug6683775 {
|
||||||
BufferedImage capture =
|
BufferedImage capture =
|
||||||
robot.createScreenCapture(new Rectangle(LOC, LOC, SIZE, SIZE));
|
robot.createScreenCapture(new Rectangle(LOC, LOC, SIZE, SIZE));
|
||||||
|
|
||||||
|
SwingUtilities.invokeAndWait(testFrame::dispose);
|
||||||
|
|
||||||
int redRGB = Color.RED.getRGB();
|
int redRGB = Color.RED.getRGB();
|
||||||
if (redRGB != capture.getRGB(SIZE/2, SIZE/2)) {
|
if (redRGB != capture.getRGB(SIZE/2, SIZE/2)) {
|
||||||
throw new RuntimeException("Transparent frame is not transparent!");
|
throw new RuntimeException("Transparent frame is not transparent!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setOpaque(Window window, boolean opaque) {
|
||||||
|
Color bg = window.getBackground();
|
||||||
|
if (bg == null) {
|
||||||
|
bg = new Color(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
window.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue(),
|
||||||
|
opaque ? 255 : 0));
|
||||||
|
}
|
||||||
|
|
||||||
private static GraphicsConfiguration getGC() {
|
private static GraphicsConfiguration getGC() {
|
||||||
GraphicsConfiguration transparencyCapableGC =
|
GraphicsConfiguration transparencyCapableGC =
|
||||||
GraphicsEnvironment.getLocalGraphicsEnvironment()
|
GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||||
.getDefaultScreenDevice().getDefaultConfiguration();
|
.getDefaultScreenDevice().getDefaultConfiguration();
|
||||||
if (!AWTUtilities.isTranslucencyCapable(transparencyCapableGC)) {
|
if (!transparencyCapableGC.isTranslucencyCapable()) {
|
||||||
transparencyCapableGC = null;
|
transparencyCapableGC = null;
|
||||||
|
|
||||||
GraphicsEnvironment env =
|
GraphicsEnvironment env =
|
||||||
|
@ -98,7 +112,7 @@ public class bug6683775 {
|
||||||
for (int i = 0; i < devices.length && transparencyCapableGC == null; i++) {
|
for (int i = 0; i < devices.length && transparencyCapableGC == null; i++) {
|
||||||
GraphicsConfiguration[] configs = devices[i].getConfigurations();
|
GraphicsConfiguration[] configs = devices[i].getConfigurations();
|
||||||
for (int j = 0; j < configs.length && transparencyCapableGC == null; j++) {
|
for (int j = 0; j < configs.length && transparencyCapableGC == null; j++) {
|
||||||
if (AWTUtilities.isTranslucencyCapable(configs[j])) {
|
if (configs[j].isTranslucencyCapable()) {
|
||||||
transparencyCapableGC = configs[j];
|
transparencyCapableGC = configs[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -22,15 +22,20 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* @test
|
/* @test
|
||||||
@bug 6726866
|
@bug 6726866 8186617
|
||||||
@summary Repainting artifacts when resizing or dragging JInternalFrames in non-opaque toplevel
|
@summary Repainting artifacts when resizing or dragging JInternalFrames in
|
||||||
@author Alexander Potochkin
|
non-opaque toplevel
|
||||||
@run applet/manual=yesno bug6726866.html
|
@run applet/manual=yesno bug6726866.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.Color;
|
||||||
import java.awt.*;
|
import java.awt.Window;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
import javax.swing.JApplet;
|
||||||
|
import javax.swing.JDesktopPane;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JInternalFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
public class bug6726866 extends JApplet {
|
public class bug6726866 extends JApplet {
|
||||||
|
|
||||||
|
@ -54,14 +59,12 @@ public class bug6726866 extends JApplet {
|
||||||
frame.toFront();
|
frame.toFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setWindowNonOpaque(Window w) {
|
public static void setWindowNonOpaque(Window window) {
|
||||||
try {
|
Color bg = window.getBackground();
|
||||||
Class<?> c = Class.forName("com.sun.awt.AWTUtilities");
|
if (bg == null) {
|
||||||
Method m = c.getMethod("setWindowOpaque", Window.class, boolean.class);
|
bg = new Color(0, 0, 0, 0);
|
||||||
m.invoke(null, w, false);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
window.setBackground(
|
||||||
|
new Color(bg.getRed(), bg.getGreen(), bg.getBlue(), 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -21,23 +21,33 @@
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.sun.awt.AWTUtilities;
|
import java.awt.AlphaComposite;
|
||||||
import sun.awt.SunToolkit;
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics;
|
||||||
import javax.swing.*;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.*;
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Robot;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.Window;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
import sun.awt.SunToolkit;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@test
|
@test
|
||||||
@key headful
|
@key headful
|
||||||
@bug 7156657
|
@bug 7156657 8186617
|
||||||
@summary Version 7 doesn't support translucent popup menus against a translucent window
|
@summary Version 7 doesn't support translucent popup menus against a
|
||||||
|
translucent window
|
||||||
@library ../../regtesthelpers
|
@library ../../regtesthelpers
|
||||||
@author Pavel Porvatov
|
@modules java.desktop/sun.awt
|
||||||
@modules java.desktop/com.sun.awt
|
|
||||||
java.desktop/sun.awt
|
|
||||||
*/
|
*/
|
||||||
public class bug7156657 {
|
public class bug7156657 {
|
||||||
private static JFrame lowerFrame;
|
private static JFrame lowerFrame;
|
||||||
|
@ -54,8 +64,7 @@ public class bug7156657 {
|
||||||
@Override
|
@Override
|
||||||
public Boolean call() throws Exception {
|
public Boolean call() throws Exception {
|
||||||
frame = createFrame();
|
frame = createFrame();
|
||||||
|
if (!frame.getGraphicsConfiguration().isTranslucencyCapable()) {
|
||||||
if (!AWTUtilities.isTranslucencyCapable(frame.getGraphicsConfiguration())) {
|
|
||||||
System.out.println("Translucency is not supported, the test skipped");
|
System.out.println("Translucency is not supported, the test skipped");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -71,7 +80,7 @@ public class bug7156657 {
|
||||||
popupMenu.add(new TransparentMenuItem("2222"));
|
popupMenu.add(new TransparentMenuItem("2222"));
|
||||||
popupMenu.add(new TransparentMenuItem("3333"));
|
popupMenu.add(new TransparentMenuItem("3333"));
|
||||||
|
|
||||||
AWTUtilities.setWindowOpaque(frame, false);
|
setOpaque(frame, false);
|
||||||
JPanel pnContent = new JPanel();
|
JPanel pnContent = new JPanel();
|
||||||
pnContent.setBackground(new Color(255, 255, 255, 128));
|
pnContent.setBackground(new Color(255, 255, 255, 128));
|
||||||
frame.add(pnContent);
|
frame.add(pnContent);
|
||||||
|
@ -132,6 +141,14 @@ public class bug7156657 {
|
||||||
System.out.println("The test passed");
|
System.out.println("The test passed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setOpaque(Window window, boolean opaque) {
|
||||||
|
Color bg = window.getBackground();
|
||||||
|
if (bg == null) {
|
||||||
|
bg = new Color(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
window.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue(),
|
||||||
|
opaque ? 255 : 0));
|
||||||
|
}
|
||||||
|
|
||||||
private static JFrame createFrame() {
|
private static JFrame createFrame() {
|
||||||
JFrame result = new JFrame();
|
JFrame result = new JFrame();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue