/* * Copyright (c) 2015, 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. */ import java.awt.Canvas; import java.awt.Component; import java.awt.Color; import java.awt.EventQueue; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; /** * @test * @bug 7011935 * @summary Verifies a fullscreen window with proper background is shown. * @run main/manual AWTFullscreenTest */ public class AWTFullScreenTest { public static void main(String[] arg) throws Exception { try { String temp1 = "The test should show a red canvas on topleft"; String temp2 = " corner of blue fullscreen window"; SwingUtilities.invokeAndWait(() -> { JOptionPane.showMessageDialog( (Component) null, temp1.concat(temp2), "information", JOptionPane.INFORMATION_MESSAGE); }); final GraphicsDevice screen = GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice(); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.getContentPane().setBackground(Color.BLUE); frame.getContentPane().setLayout(null); frame.setUndecorated(true); Canvas canvas = new Canvas(); canvas.setBackground(Color.RED); canvas.setBounds(10, 10, 100, 100); frame.getContentPane().add(canvas); System.out.println("isFullscreenSupported=" + screen.isFullScreenSupported()); screen.setFullScreenWindow(frame); Thread.sleep(5000); String str1 = "Did a blue fullscreen window"; String str2 = " was shown with red canvas on top?"; SwingUtilities.invokeAndWait(() -> { int confirm = JOptionPane.showConfirmDialog( (Component) null, str1.concat(str2), "alert", JOptionPane.YES_NO_OPTION); if (confirm == JOptionPane.YES_OPTION) { System.out.println("Test passed"); } else { System.out.println("Test failed"); throw new RuntimeException("Fullscreen window not shown"); } }); SwingUtilities.invokeLater(() -> { frame.dispose(); }); } catch (Exception e) {} } }