1 /* 2 * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 package java.awt; 26 27 import java.awt.event.*; 28 import java.awt.geom.Path2D; 29 import java.awt.geom.Point2D; 30 import java.awt.im.InputContext; 31 import java.awt.image.BufferStrategy; 32 import java.awt.peer.ComponentPeer; 33 import java.awt.peer.WindowPeer; 34 import java.beans.PropertyChangeListener; 35 import java.io.IOException; 36 import java.io.ObjectInputStream; 37 import java.io.ObjectOutputStream; 38 import java.io.OptionalDataException; 39 import java.io.Serializable; 40 import java.lang.ref.WeakReference; 41 import java.lang.reflect.InvocationTargetException; 42 import java.security.AccessController; 43 import java.util.ArrayList; 44 import java.util.Arrays; 45 import java.util.EventListener; 46 import java.util.Locale; 47 import java.util.ResourceBundle; 48 import java.util.Set; 49 import java.util.Vector; 50 import java.util.concurrent.atomic.AtomicBoolean; 51 import javax.accessibility.*; 52 import sun.awt.AWTAccessor; 53 import sun.awt.AWTPermissions; 54 import sun.awt.AppContext; 55 import sun.awt.DebugSettings; 56 import sun.awt.SunToolkit; 57 import sun.awt.util.IdentityArrayList; 58 import sun.java2d.pipe.Region; 59 import sun.security.action.GetPropertyAction; 60 import sun.util.logging.PlatformLogger; 61 62 /** 63 * A {@code Window} object is a top-level window with no borders and no 64 * menubar. 65 * The default layout for a window is {@code BorderLayout}. 66 * <p> 67 * A window must have either a frame, dialog, or another window defined as its 68 * owner when it's constructed. 69 * <p> 70 * In a multi-screen environment, you can create a {@code Window} 71 * on a different screen device by constructing the {@code Window} 4033 GraphicsConfiguration graphicsConfig = 4034 getGraphicsConfiguration_NoClientCode(); 4035 Rectangle screenBounds = graphicsConfig.getBounds(); 4036 Insets screenInsets = 4037 Toolkit.getDefaultToolkit().getScreenInsets(graphicsConfig); 4038 4039 wx = Window.limit(wx, 4040 screenBounds.x + screenInsets.left, 4041 screenBounds.x + screenBounds.width - screenInsets.right 4042 - securityWarningWidth); 4043 wy = Window.limit(wy, 4044 screenBounds.y + screenInsets.top, 4045 screenBounds.y + screenBounds.height - screenInsets.bottom 4046 - securityWarningHeight); 4047 4048 return new Point2D.Double(wx, wy); 4049 } 4050 4051 static { 4052 AWTAccessor.setWindowAccessor(new AWTAccessor.WindowAccessor() { 4053 public float getOpacity(Window window) { 4054 return window.opacity; 4055 } 4056 public void setOpacity(Window window, float opacity) { 4057 window.setOpacity(opacity); 4058 } 4059 public Shape getShape(Window window) { 4060 return window.getShape(); 4061 } 4062 public void setShape(Window window, Shape shape) { 4063 window.setShape(shape); 4064 } 4065 public void setOpaque(Window window, boolean opaque) { 4066 Color bg = window.getBackground(); 4067 if (bg == null) { 4068 bg = new Color(0, 0, 0, 0); 4069 } 4070 window.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue(), 4071 opaque ? 255 : 0)); 4072 } 4073 public void updateWindow(Window window) { 4074 window.updateWindow(); 4075 } 4076 4077 public Dimension getSecurityWarningSize(Window window) { 4078 return new Dimension(window.securityWarningWidth, 4079 window.securityWarningHeight); 4080 } 4081 4082 public void setSecurityWarningSize(Window window, int width, int height) 4083 { 4084 window.securityWarningWidth = width; 4085 window.securityWarningHeight = height; 4086 } 4087 4088 public void setSecurityWarningPosition(Window window, 4089 Point2D point, float alignmentX, float alignmentY) 4090 { 4091 window.securityWarningPointX = point.getX(); 4092 window.securityWarningPointY = point.getY(); | 1 /* 2 * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.awt; 27 28 import java.awt.event.ComponentEvent; 29 import java.awt.event.FocusEvent; 30 import java.awt.event.KeyEvent; 31 import java.awt.event.MouseWheelEvent; 32 import java.awt.event.WindowEvent; 33 import java.awt.event.WindowFocusListener; 34 import java.awt.event.WindowListener; 35 import java.awt.event.WindowStateListener; 36 import java.awt.geom.Path2D; 37 import java.awt.geom.Point2D; 38 import java.awt.im.InputContext; 39 import java.awt.image.BufferStrategy; 40 import java.awt.peer.ComponentPeer; 41 import java.awt.peer.WindowPeer; 42 import java.beans.PropertyChangeListener; 43 import java.io.IOException; 44 import java.io.ObjectInputStream; 45 import java.io.ObjectOutputStream; 46 import java.io.OptionalDataException; 47 import java.io.Serializable; 48 import java.lang.ref.WeakReference; 49 import java.lang.reflect.InvocationTargetException; 50 import java.security.AccessController; 51 import java.util.ArrayList; 52 import java.util.Arrays; 53 import java.util.EventListener; 54 import java.util.Locale; 55 import java.util.ResourceBundle; 56 import java.util.Set; 57 import java.util.Vector; 58 import java.util.concurrent.atomic.AtomicBoolean; 59 60 import javax.accessibility.Accessible; 61 import javax.accessibility.AccessibleContext; 62 import javax.accessibility.AccessibleRole; 63 import javax.accessibility.AccessibleState; 64 import javax.accessibility.AccessibleStateSet; 65 66 import sun.awt.AWTAccessor; 67 import sun.awt.AWTPermissions; 68 import sun.awt.AppContext; 69 import sun.awt.DebugSettings; 70 import sun.awt.SunToolkit; 71 import sun.awt.util.IdentityArrayList; 72 import sun.java2d.pipe.Region; 73 import sun.security.action.GetPropertyAction; 74 import sun.util.logging.PlatformLogger; 75 76 /** 77 * A {@code Window} object is a top-level window with no borders and no 78 * menubar. 79 * The default layout for a window is {@code BorderLayout}. 80 * <p> 81 * A window must have either a frame, dialog, or another window defined as its 82 * owner when it's constructed. 83 * <p> 84 * In a multi-screen environment, you can create a {@code Window} 85 * on a different screen device by constructing the {@code Window} 4047 GraphicsConfiguration graphicsConfig = 4048 getGraphicsConfiguration_NoClientCode(); 4049 Rectangle screenBounds = graphicsConfig.getBounds(); 4050 Insets screenInsets = 4051 Toolkit.getDefaultToolkit().getScreenInsets(graphicsConfig); 4052 4053 wx = Window.limit(wx, 4054 screenBounds.x + screenInsets.left, 4055 screenBounds.x + screenBounds.width - screenInsets.right 4056 - securityWarningWidth); 4057 wy = Window.limit(wy, 4058 screenBounds.y + screenInsets.top, 4059 screenBounds.y + screenBounds.height - screenInsets.bottom 4060 - securityWarningHeight); 4061 4062 return new Point2D.Double(wx, wy); 4063 } 4064 4065 static { 4066 AWTAccessor.setWindowAccessor(new AWTAccessor.WindowAccessor() { 4067 public void updateWindow(Window window) { 4068 window.updateWindow(); 4069 } 4070 4071 public Dimension getSecurityWarningSize(Window window) { 4072 return new Dimension(window.securityWarningWidth, 4073 window.securityWarningHeight); 4074 } 4075 4076 public void setSecurityWarningSize(Window window, int width, int height) 4077 { 4078 window.securityWarningWidth = width; 4079 window.securityWarningHeight = height; 4080 } 4081 4082 public void setSecurityWarningPosition(Window window, 4083 Point2D point, float alignmentX, float alignmentY) 4084 { 4085 window.securityWarningPointX = point.getX(); 4086 window.securityWarningPointY = point.getY(); |