1 /* 2 * Copyright (c) 2013, 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. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 import java.awt.Color; 26 import java.awt.Frame; 27 import java.awt.GraphicsDevice; 28 import java.awt.GraphicsEnvironment; 29 import java.lang.reflect.InvocationTargetException; 30 31 import javax.swing.SwingUtilities; 32 33 /** 34 * @test 35 * @key headful 36 * @bug 8019591 37 * @author Sergey Bylokhov 38 */ 39 public class WindowGCInFullScreen { 40 41 public static void main(final String[] args) 42 throws InvocationTargetException, InterruptedException { 43 SwingUtilities.invokeAndWait(() -> { 44 final GraphicsDevice[] devices = 45 GraphicsEnvironment.getLocalGraphicsEnvironment() 46 .getScreenDevices(); 47 final Frame frame = new Frame(); 48 frame.setBackground(Color.GREEN); 49 frame.setUndecorated(true); 50 frame.setSize(100, 100); 51 frame.setLocationRelativeTo(null); 52 frame.setVisible(true); 53 sleep(); 54 for (final GraphicsDevice gd : devices) { 55 try { 56 gd.setFullScreenWindow(frame); 57 if (gd.getFullScreenWindow() != frame) { 58 throw new RuntimeException("Wrong window"); 59 } 60 if (frame.getGraphicsConfiguration().getDevice() != gd) { 61 throw new RuntimeException("Wrong new GraphicsDevice"); 62 } 63 } finally { 64 // cleaning up 65 gd.setFullScreenWindow(null); 66 } 67 } 68 frame.dispose(); 69 }); 70 } 71 72 private static void sleep() { 73 try { 74 Thread.sleep(1000); 75 } catch (InterruptedException ignored) { 76 } 77 } 78 }