< prev index next >

test/jdk/java/awt/event/ComponentEvent/MovedResizedTwiceTest/MovedResizedTwiceTest.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /*
  27   @test
  28   @bug 5025858
  29   @summary Tests that after programmatically moving or resizing a component,
  30 corresponding ComponentEvents are generated only once
  31   @author artem.ananiev: area=awt.event
  32   @run main/manual MovedResizedTwiceTest
  33 */
  34 
  35 import java.awt.*;
  36 import java.awt.event.*;







  37 
  38 /*
  39   IMPORTANT: this test is made manual as some window managers may generate
  40   strange events and that would lead to the test to fail. However, on most
  41   popular platforms (windows, linux w/ KDE or GNOME, solaris w/ CDE or
  42   GNOME) it usually passes successfully.
  43 */
  44 
  45 public class MovedResizedTwiceTest
  46 {
  47     private static volatile int componentMovedCount;
  48     private static volatile int componentResizedCount;
  49 
  50     private static volatile int rightX, rightY;
  51 
  52     private static volatile boolean failed = false;
  53 
  54     private static void init()
  55     {
  56         componentMovedCount = componentResizedCount = 0;
  57 
  58         Robot robot;
  59         try {


   1 /*
   2  * Copyright (c) 2005, 2019, 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.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /*
  27   @test
  28   @bug 5025858 8144125
  29   @summary Tests that after programmatically moving or resizing a component,
  30            corresponding ComponentEvents are generated only once


  31 */
  32 
  33 import java.awt.Button;
  34 import java.awt.Component;
  35 import java.awt.Frame;
  36 import java.awt.Point;
  37 import java.awt.Robot;
  38 import java.awt.Window;
  39 import java.awt.event.ComponentAdapter;
  40 import java.awt.event.ComponentEvent;
  41 import java.awt.event.ComponentListener;
  42 
  43 /*
  44   IMPORTANT: this test can fail because some window managers may generate
  45   strange events and that would lead to the test to fail. However, on most
  46   popular platforms (windows, linux w/ KDE or GNOME, solaris w/ CDE or
  47   GNOME) it usually passes successfully.
  48 */
  49 
  50 public class MovedResizedTwiceTest
  51 {
  52     private static volatile int componentMovedCount;
  53     private static volatile int componentResizedCount;
  54 
  55     private static volatile int rightX, rightY;
  56 
  57     private static volatile boolean failed = false;
  58 
  59     private static void init()
  60     {
  61         componentMovedCount = componentResizedCount = 0;
  62 
  63         Robot robot;
  64         try {


< prev index next >