1 /* 2 * Copyright (c) 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. 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 /* @test 25 * @bug 8157163 26 * @summary AWT FileDialog does not inherit icon image from parent Frame 27 * @requires os.family=="windows" 28 * @run main FileDialogIconTest 29 */ 30 import javax.swing.*; 31 import java.awt.*; 32 import java.awt.image.BufferedImage; 33 import java.lang.reflect.InvocationTargetException; 34 35 public class FileDialogIconTest { 36 private static Frame frame; 37 private static Dialog dialog; 38 39 public static void main(final String[] args) throws InterruptedException, InvocationTargetException, AWTException { 40 Robot robot; 41 Point p; 42 try { 43 frame = new Frame(); 44 frame.setIconImage(createImage()); 45 frame.setVisible(true); 46 robot = new Robot(); 47 robot.waitForIdle(); 48 robot.delay(200); 49 50 dialog = new FileDialog(frame, "Dialog"); 51 dialog.setModal(false); 52 dialog.setVisible(true); 53 robot.waitForIdle(); 54 robot.delay(200); 55 56 p = new Point(10, 10); 57 SwingUtilities.convertPointToScreen(p, dialog); 58 Color color = robot.getPixelColor(p.x, p.y); 59 if (!Color.RED.equals(color)) { 60 throw new RuntimeException("Dialog icon was not inherited from " + 61 "owning window. Wrong color: " + color); 62 } 63 } finally { 64 dialog.dispose(); 65 frame.dispose(); 66 } 67 } 68 69 private static Image createImage() { 70 BufferedImage image = new BufferedImage(64, 64, 71 BufferedImage.TYPE_INT_ARGB); 72 Graphics g = image.getGraphics(); 73 g.setColor(Color.RED); 74 g.fillRect(0, 0, image.getWidth(), image.getHeight()); 75 g.dispose(); 76 return image; 77 } 78 79 }