test/jdk/java/awt/Toolkit/Headless/AWTEventListener/AWTListener.java
changeset 50834 9cf279436b9d
parent 47216 71c04702a3d5
equal deleted inserted replaced
50833:97852c0a7a91 50834:9cf279436b9d
     1 /*
     1 /*
     2  * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    46 
    46 
    47         AWTEventListener orig = new AWTEventListener() {
    47         AWTEventListener orig = new AWTEventListener() {
    48                 public void eventDispatched(AWTEvent event) { }
    48                 public void eventDispatched(AWTEvent event) { }
    49             };
    49             };
    50 
    50 
    51         Sysout.println("Test: listener to add = " +orig);
    51         System.out.println("Test: listener to add = " +orig);
    52         toolkit.addAWTEventListener(orig, AWTEvent.CONTAINER_EVENT_MASK);
    52         toolkit.addAWTEventListener(orig, AWTEvent.CONTAINER_EVENT_MASK);
    53 
    53 
    54         for (AWTEventListener l: toolkit.getAWTEventListeners()){
    54         for (AWTEventListener l: toolkit.getAWTEventListeners()){
    55             Sysout.println("Test: listener = " +l+" ");
    55             System.out.println("Test: listener = " +l+" ");
    56         }
    56         }
    57 
    57 
    58         if ( toolkit.getAWTEventListeners().length == 0 ) {
    58         if ( toolkit.getAWTEventListeners().length == 0 ) {
    59             throw new RuntimeException("Case 1. An empty array returned unexpectedly");
    59             throw new RuntimeException("Case 1. An empty array returned unexpectedly");
    60         }
    60         }
    61 
    61 
    62         for (AWTEventListener l: toolkit.getAWTEventListeners(AWTEvent.CONTAINER_EVENT_MASK)){
    62         for (AWTEventListener l: toolkit.getAWTEventListeners(AWTEvent.CONTAINER_EVENT_MASK)){
    63             Sysout.println("Test: listener = " +l);
    63             System.out.println("Test: listener = " +l);
    64          }
    64          }
    65 
    65 
    66         if ( toolkit.getAWTEventListeners(AWTEvent.CONTAINER_EVENT_MASK).length == 0 ) {
    66         if ( toolkit.getAWTEventListeners(AWTEvent.CONTAINER_EVENT_MASK).length == 0 ) {
    67             throw new RuntimeException("Case 2. An empty array returned unexpectedly");
    67             throw new RuntimeException("Case 2. An empty array returned unexpectedly");
    68         }
    68         }
    69         Sysout.println("Test PASSED");
    69         System.out.println("Test PASSED");
    70     }
    70     }
    71 }
    71 }