test/jdk/java/awt/event/MouseEvent/FrameMouseEventAbsoluteCoordsTest/FrameMouseEventAbsoluteCoordsTest.java
changeset 54231 e4813eded7cb
parent 47216 71c04702a3d5
equal deleted inserted replaced
54230:d9d9655bb077 54231:e4813eded7cb
     1 /*
     1 /*
     2  * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2004, 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.
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25   test
    25   @test
       
    26   @key headful
    26   @bug 4992908
    27   @bug 4992908
    27   @summary Need way to get location of MouseEvent in screen  coordinates (Unit-test)
    28   @summary Need way to get location of MouseEvent in screen  coordinates (Unit-test)
    28   @author Andrei.Dmitriev area=event
    29   @library ../../../regtesthelpers
    29   @run applet FrameMouseEventAbsoluteCoordsTest.html
    30   @build Util
       
    31   @run main FrameMouseEventAbsoluteCoordsTest
    30 */
    32 */
    31 
    33 
    32 import java.applet.Applet;
       
    33 import java.awt.*;
    34 import java.awt.*;
    34 import java.awt.event.*;
    35 import java.awt.event.*;
    35 import test.java.awt.regtesthelpers.Util;
    36 import test.java.awt.regtesthelpers.Util;
    36 
    37 
    37 // Part II
    38 // Part II
    38 // Create Frame.
    39 // Create Frame.
    39 // Click on this frame.
    40 // Click on this frame.
    40 // verify that our MouseEvent contain correct xAbs, yAbs values
    41 // verify that our MouseEvent contain correct xAbs, yAbs values
    41 
    42 
    42 public class FrameMouseEventAbsoluteCoordsTest extends Applet implements MouseListener
    43 public class FrameMouseEventAbsoluteCoordsTest implements MouseListener
    43 {
    44 {
    44     Robot robot;
    45     Robot robot;
    45     Frame frame = new Frame("MouseEvent Test Frame II");
    46     Frame frame = new Frame("MouseEvent Test Frame II");
    46     Button button = new Button("Just Button");
    47     Button button = new Button("Just Button");
    47     Point mousePositionAbsolute;
    48     Point mousePositionAbsolute;
    48     Point mousePosition;
    49     Point mousePosition;
    49 
    50 
       
    51     public static void main(final String[] args) {
       
    52         FrameMouseEventAbsoluteCoordsTest app = new FrameMouseEventAbsoluteCoordsTest();
       
    53         app.init();
       
    54         app.start();
       
    55     }
       
    56 
    50     public void init()
    57     public void init()
    51     {
    58     {
    52 
       
    53         this.setLayout (new BorderLayout ());
       
    54         button.addMouseListener(this);
    59         button.addMouseListener(this);
    55         frame.add(button);
    60         frame.add(button);
    56         frame.pack();
    61         frame.pack();
       
    62         frame.setLocationRelativeTo(null);
    57     }//End  init()
    63     }//End  init()
    58 
    64 
    59     public void start ()
    65     public void start ()
    60     {
    66     {
    61         setSize (200,200);
       
    62         frame.setVisible(true);
    67         frame.setVisible(true);
    63         validate();
       
    64         Util.waitForIdle(robot);
    68         Util.waitForIdle(robot);
    65 
    69 
    66         try {
    70         try {
    67             robot = new Robot();
    71             robot = new Robot();
    68             robot.setAutoWaitForIdle(true);
    72             robot.setAutoWaitForIdle(true);