8173409: make setMixingCutoutShape public and remove jdk.desktop
Reviewed-by: serb, mchung, alexsch
This commit is contained in:
parent
2679fdea07
commit
e9dd1485e6
@ -456,8 +456,7 @@ public final class AWTUtilities {
|
|||||||
"The component argument should not be null.");
|
"The component argument should not be null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
AWTAccessor.getComponentAccessor().setMixingCutoutShape(component,
|
component.setMixingCutoutShape(shape);
|
||||||
shape);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10380,7 +10380,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a 'mixing-cutout' shape for the given component.
|
* Sets a 'mixing-cutout' shape for this lightweight component.
|
||||||
|
*
|
||||||
|
* This method is used exclusively for the purposes of the
|
||||||
|
* Heavyweight/Lightweight Components Mixing feature and will
|
||||||
|
* have no effect if applied to a heavyweight component.
|
||||||
*
|
*
|
||||||
* By default a lightweight component is treated as an opaque rectangle for
|
* By default a lightweight component is treated as an opaque rectangle for
|
||||||
* the purposes of the Heavyweight/Lightweight Components Mixing feature.
|
* the purposes of the Heavyweight/Lightweight Components Mixing feature.
|
||||||
@ -10393,7 +10397,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
|||||||
* <li>{@code null} - reverts the default cutout shape (the rectangle equal
|
* <li>{@code null} - reverts the default cutout shape (the rectangle equal
|
||||||
* to the component's {@code getBounds()})
|
* to the component's {@code getBounds()})
|
||||||
* <li><i>empty-shape</i> - does not cut out anything from heavyweight
|
* <li><i>empty-shape</i> - does not cut out anything from heavyweight
|
||||||
* components. This makes the given lightweight component effectively
|
* components. This makes this lightweight component effectively
|
||||||
* transparent. Note that descendants of the lightweight component still
|
* transparent. Note that descendants of the lightweight component still
|
||||||
* affect the shapes of heavyweight components. An example of an
|
* affect the shapes of heavyweight components. An example of an
|
||||||
* <i>empty-shape</i> is {@code new Rectangle()}.
|
* <i>empty-shape</i> is {@code new Rectangle()}.
|
||||||
@ -10407,16 +10411,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
|||||||
* for the given glass pane component. If a developer needs some other
|
* for the given glass pane component. If a developer needs some other
|
||||||
* 'mixing-cutout' shape for the glass pane (which is rare), this must be
|
* 'mixing-cutout' shape for the glass pane (which is rare), this must be
|
||||||
* changed manually after installing the glass pane to the root pane.
|
* changed manually after installing the glass pane to the root pane.
|
||||||
* <p>
|
|
||||||
* Note that the 'mixing-cutout' shape neither affects painting, nor the
|
|
||||||
* mouse events handling for the given component. It is used exclusively
|
|
||||||
* for the purposes of the Heavyweight/Lightweight Components Mixing
|
|
||||||
* feature.
|
|
||||||
*
|
*
|
||||||
* @param shape the new 'mixing-cutout' shape
|
* @param shape the new 'mixing-cutout' shape
|
||||||
* @since 9
|
* @since 9
|
||||||
*/
|
*/
|
||||||
void setMixingCutoutShape(Shape shape) {
|
public void setMixingCutoutShape(Shape shape) {
|
||||||
Region region = shape == null ? null : Region.getInstance(shape, null);
|
Region region = shape == null ? null : Region.getInstance(shape, null);
|
||||||
|
|
||||||
synchronized (getTreeLock()) {
|
synchronized (getTreeLock()) {
|
||||||
|
@ -286,8 +286,7 @@ public final class JLayer<V extends Component>
|
|||||||
super.remove(oldGlassPane);
|
super.remove(oldGlassPane);
|
||||||
}
|
}
|
||||||
if (glassPane != null) {
|
if (glassPane != null) {
|
||||||
AWTAccessor.getComponentAccessor().setMixingCutoutShape(glassPane,
|
glassPane.setMixingCutoutShape(new Rectangle());
|
||||||
new Rectangle());
|
|
||||||
glassPane.setVisible(isGlassPaneVisible);
|
glassPane.setVisible(isGlassPaneVisible);
|
||||||
super.addImpl(glassPane, null, 0);
|
super.addImpl(glassPane, null, 0);
|
||||||
}
|
}
|
||||||
|
@ -663,8 +663,7 @@ public class JRootPane extends JComponent implements Accessible {
|
|||||||
throw new NullPointerException("glassPane cannot be set to null.");
|
throw new NullPointerException("glassPane cannot be set to null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
AWTAccessor.getComponentAccessor().setMixingCutoutShape(glass,
|
glass.setMixingCutoutShape(new Rectangle());
|
||||||
new Rectangle());
|
|
||||||
|
|
||||||
boolean visible = false;
|
boolean visible = false;
|
||||||
if (glassPane != null && glassPane.getParent() == this) {
|
if (glassPane != null && glassPane.getParent() == this) {
|
||||||
|
@ -88,9 +88,6 @@ module java.desktop {
|
|||||||
exports sun.awt to
|
exports sun.awt to
|
||||||
jdk.accessibility;
|
jdk.accessibility;
|
||||||
|
|
||||||
exports com.sun.awt to
|
|
||||||
jdk.desktop;
|
|
||||||
|
|
||||||
opens javax.swing.plaf.basic to
|
opens javax.swing.plaf.basic to
|
||||||
jdk.jconsole;
|
jdk.jconsole;
|
||||||
opens com.sun.java.swing.plaf.windows to
|
opens com.sun.java.swing.plaf.windows to
|
||||||
|
@ -93,12 +93,6 @@ public final class AWTAccessor {
|
|||||||
* its parent.
|
* its parent.
|
||||||
*/
|
*/
|
||||||
Rectangle getBounds(Component comp);
|
Rectangle getBounds(Component comp);
|
||||||
/*
|
|
||||||
* Sets the shape of a lw component to cut out from hw components.
|
|
||||||
*
|
|
||||||
* See 6797587, 6776743, 6768307, and 6768332 for details
|
|
||||||
*/
|
|
||||||
void setMixingCutoutShape(Component comp, Shape shape);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets GraphicsConfiguration value for the component.
|
* Sets GraphicsConfiguration value for the component.
|
||||||
|
@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle in the LICENSE file that accompanied this code.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package jdk.awt;
|
|
||||||
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.Shape;
|
|
||||||
|
|
||||||
import com.sun.awt.AWTUtilities;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A class to allow access to JDK-specific utility methods.
|
|
||||||
* Methods in this class are always deprecated since a caller
|
|
||||||
* should be aware they may be removed and replaced in the future.
|
|
||||||
* Access using reflection is highly recommended.
|
|
||||||
* @since 9
|
|
||||||
*/
|
|
||||||
public final class AWTUtils {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No-one should be creating instances of this class.
|
|
||||||
*/
|
|
||||||
private AWTUtils() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a 'mixing-cutout' shape for the given component.
|
|
||||||
*
|
|
||||||
* By default a lightweight component is treated as an opaque rectangle for
|
|
||||||
* the purposes of the Heavyweight/Lightweight Components Mixing feature.
|
|
||||||
* This method enables developers to set an arbitrary shape to be cut out
|
|
||||||
* from heavyweight components positioned underneath the lightweight
|
|
||||||
* component in the z-order.
|
|
||||||
* <p>
|
|
||||||
* The {@code shape} argument may have the following values:
|
|
||||||
* <ul>
|
|
||||||
* <li>{@code null} - reverts the default cutout shape (the rectangle equal
|
|
||||||
* to the component's {@code getBounds()})
|
|
||||||
* <li><i>empty-shape</i> - does not cut out anything from heavyweight
|
|
||||||
* components. This makes the given lightweight component effectively
|
|
||||||
* transparent. Note that descendants of the lightweight component still
|
|
||||||
* affect the shapes of heavyweight components. An example of an
|
|
||||||
* <i>empty-shape</i> is {@code new Rectangle()}.
|
|
||||||
* <li><i>non-empty-shape</i> - the given shape will be cut out from
|
|
||||||
* heavyweight components.
|
|
||||||
* </ul>
|
|
||||||
* <p>
|
|
||||||
* The most common example when the 'mixing-cutout' shape is needed is a
|
|
||||||
* glass pane component. The {@link JRootPane#setGlassPane()} method
|
|
||||||
* automatically sets the <i>empty-shape</i> as the 'mixing-cutout' shape
|
|
||||||
* for the given glass pane component. If a developer needs some other
|
|
||||||
* 'mixing-cutout' shape for the glass pane (which is rare), this must be
|
|
||||||
* changed manually after installing the glass pane to the root pane.
|
|
||||||
* <p>
|
|
||||||
* Note that the 'mixing-cutout' shape neither affects painting, nor the
|
|
||||||
* mouse events handling for the given component. It is used exclusively
|
|
||||||
* for the purposes of the Heavyweight/Lightweight Components Mixing
|
|
||||||
* feature.
|
|
||||||
*
|
|
||||||
* @param component the component that needs non-default
|
|
||||||
* 'mixing-cutout' shape
|
|
||||||
* @param shape the new 'mixing-cutout' shape
|
|
||||||
* @throws NullPointerException if the component argument is {@code null}
|
|
||||||
* @deprecated This API may be removed or replaced.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static void setComponentMixingCutoutShape(Component component,
|
|
||||||
Shape shape) {
|
|
||||||
|
|
||||||
AWTUtilities.setComponentMixingCutoutShape(component, shape);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle in the LICENSE file that accompanied this code.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Provides non-SE desktop APIs.
|
|
||||||
*/
|
|
||||||
|
|
||||||
module jdk.desktop {
|
|
||||||
requires transitive java.desktop;
|
|
||||||
|
|
||||||
exports jdk.awt;
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 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,7 +22,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import com.sun.awt.AWTUtilities;
|
|
||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
import java.awt.Panel;
|
import java.awt.Panel;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
@ -44,11 +43,10 @@ import test.java.awt.regtesthelpers.Util;
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @key headful
|
* @key headful
|
||||||
* @bug 6776743
|
* @bug 6776743 8173409
|
||||||
* @summary Opaque overlapping test for each AWT component
|
* @summary Opaque overlapping test for each AWT component
|
||||||
* @library /java/awt/patchlib ../../regtesthelpers
|
* @library /java/awt/patchlib ../../regtesthelpers
|
||||||
* @modules java.desktop/com.sun.awt
|
* @modules java.desktop/java.awt.peer
|
||||||
* java.desktop/java.awt.peer
|
|
||||||
* java.desktop/sun.awt
|
* java.desktop/sun.awt
|
||||||
* @build java.desktop/java.awt.Helper
|
* @build java.desktop/java.awt.Helper
|
||||||
* @build Util
|
* @build Util
|
||||||
@ -134,12 +132,10 @@ public class OpaqueOverlapping extends OverlappingTestBase {
|
|||||||
// flag value.
|
// flag value.
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
if (i == 3) {
|
if (i == 3) {
|
||||||
AWTUtilities.setComponentMixingCutoutShape(light,
|
light.setMixingCutoutShape(new Rectangle());
|
||||||
new Rectangle());
|
|
||||||
}
|
}
|
||||||
if (i == 6) {
|
if (i == 6) {
|
||||||
AWTUtilities.setComponentMixingCutoutShape(light,
|
light.setMixingCutoutShape(null);
|
||||||
null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||||
|
@ -24,11 +24,10 @@
|
|||||||
/*
|
/*
|
||||||
@test
|
@test
|
||||||
@key headful
|
@key headful
|
||||||
@bug 4811096
|
@bug 4811096 8173409
|
||||||
@summary Tests whether opaque and non-opaque components mix correctly
|
@summary Tests whether opaque and non-opaque components mix correctly
|
||||||
@author anthony.petrov@...: area=awt.mixing
|
@author anthony.petrov@...: area=awt.mixing
|
||||||
@library ../regtesthelpers
|
@library ../regtesthelpers
|
||||||
@modules java.desktop/com.sun.awt
|
|
||||||
@build Util
|
@build Util
|
||||||
@run main OpaqueTest
|
@run main OpaqueTest
|
||||||
*/
|
*/
|
||||||
@ -44,7 +43,6 @@ import java.awt.*;
|
|||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import test.java.awt.regtesthelpers.Util;
|
import test.java.awt.regtesthelpers.Util;
|
||||||
import com.sun.awt.AWTUtilities;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -125,12 +123,10 @@ public class OpaqueTest
|
|||||||
// flag value.
|
// flag value.
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
if (i == 3) {
|
if (i == 3) {
|
||||||
AWTUtilities.setComponentMixingCutoutShape(light,
|
light.setMixingCutoutShape(new Rectangle());
|
||||||
new Rectangle());
|
|
||||||
}
|
}
|
||||||
if (i == 6) {
|
if (i == 6) {
|
||||||
AWTUtilities.setComponentMixingCutoutShape(light,
|
light.setMixingCutoutShape(null);
|
||||||
null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 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. Oracle designates this
|
|
||||||
* particular file as subject to the "Classpath" exception as provided
|
|
||||||
* by Oracle in the LICENSE file that accompanied this code.
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* @bug 8167126
|
|
||||||
*/
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
|
||||||
public class TestJDKAWTUtils {
|
|
||||||
|
|
||||||
static JFrame f;
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
|
|
||||||
SwingUtilities.invokeAndWait(() -> {
|
|
||||||
f = new JFrame("test");
|
|
||||||
JPanel p = new JPanel();
|
|
||||||
JButton b = new JButton("Hello");
|
|
||||||
b.setFont(new Font(Font.DIALOG, Font.PLAIN, 80));
|
|
||||||
p.setLayout(new BorderLayout());
|
|
||||||
p.add("Center", b);
|
|
||||||
f.getContentPane().add(p);
|
|
||||||
f.pack();
|
|
||||||
f.setVisible(true);
|
|
||||||
Rectangle r = new Rectangle(0, 0, 50, 50);
|
|
||||||
jdk.awt.AWTUtils.setComponentMixingCutoutShape(b, r);
|
|
||||||
});
|
|
||||||
Thread.sleep(2000);
|
|
||||||
SwingUtilities.invokeAndWait(() -> f.dispose());
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user