1 /* 2 * Copyright (c) 2011, 2014, 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 import java.awt.*; 25 26 /* 27 * @test 28 * @key headful 29 * @summary An attempt to set non-trivial background, shape, or translucency 30 * to a decorated toplevel should end with an exception. 31 * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) 32 * @library ../../../../lib/client 33 * @build ExtendedRobot 34 * @run main DecoratedExceptions 35 */ 36 public class DecoratedExceptions { 37 public static void main(String args[]) throws Exception{ 38 ExtendedRobot robot = new ExtendedRobot(); 39 Toolkit.getDefaultToolkit().getSystemEventQueue().invokeAndWait(() -> { 40 Frame frame = new Frame("Frame"); 41 frame.setBounds(50,50,400,200); 42 try { 43 frame.setOpacity(0.5f); 44 throw new RuntimeException("No exception when Opacity set to a decorated Frame"); 45 }catch(IllegalComponentStateException e) { 46 } 47 try { 48 frame.setShape(new Rectangle(50,50,400,200)); 49 throw new RuntimeException("No exception when Shape set to a decorated Frame"); 50 }catch(IllegalComponentStateException e) { 51 } 52 try { 53 frame.setBackground(new Color(50, 50, 50, 100)); 54 throw new RuntimeException("No exception when Alpha background set to a decorated Frame"); 55 }catch(IllegalComponentStateException e) { 56 } 57 frame.setVisible(true); 58 Dialog dialog = new Dialog( frame ); 59 try { 60 dialog.setOpacity(0.5f); 61 throw new RuntimeException("No exception when Opacity set to a decorated Dialog"); 62 }catch(IllegalComponentStateException e) { 63 } 64 try { 65 dialog.setShape(new Rectangle(50,50,400,200)); 66 throw new RuntimeException("No exception when Shape set to a decorated Dialog"); 67 }catch(IllegalComponentStateException e) { 68 } 69 try { 70 dialog.setBackground(new Color(50, 50, 50, 100)); 71 throw new RuntimeException("No exception when Alpha background set to a decorated Dialog"); 72 }catch(IllegalComponentStateException e) { 73 } 74 dialog.setVisible(true); 75 }); 76 robot.waitForIdle(1000); 77 } 78 }