test/jdk/java/awt/event/MouseEvent/MenuDragMouseEventAbsoluteCoordsTest/MenuDragMouseEventAbsoluteCoordsTest.java
changeset 54231 e4813eded7cb
parent 47216 71c04702a3d5
equal deleted inserted replaced
54230:d9d9655bb077 54231:e4813eded7cb
    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
    28   @summary Need way to get location of MouseEvent in screen coordinates
    28   @author Andrei.Dmitriev area=event
    29   @library ../../../regtesthelpers
    29   @run applet MenuDragMouseEventAbsoluteCoordsTest.html
    30   @build Util
       
    31   @run main MenuDragMouseEventAbsoluteCoordsTest
    30 */
    32 */
    31 
    33 
    32 import java.applet.Applet;
       
    33 import java.awt.*;
    34 import java.awt.*;
    34 import javax.swing.event.*;
    35 import javax.swing.event.*;
    35 import java.awt.event.*;
    36 import java.awt.event.*;
    36 import javax.swing.MenuSelectionManager;
       
    37 import javax.swing.MenuElement;
       
    38 import test.java.awt.regtesthelpers.Util;
    37 import test.java.awt.regtesthelpers.Util;
    39 
    38 
    40 // The test consits of several parts:
    39 // The test consits of several parts:
    41 // 1. create MenuDragMouseEvent with new Ctor and checking get(X|Y)OnScreen(),
    40 // 1. create MenuDragMouseEvent with new Ctor and checking get(X|Y)OnScreen(),
    42 // getLocationOnScreen(), get(X|Y), getPoint().
    41 // getLocationOnScreen(), get(X|Y), getPoint().
    43 // 2. create MenuDragMouseEvent with old Ctor and checking get(X|Y)OnScreen(),
    42 // 2. create MenuDragMouseEvent with old Ctor and checking get(X|Y)OnScreen(),
    44 // getLocationOnScreen(),  get(X|Y), getPoint() .
    43 // getLocationOnScreen(),  get(X|Y), getPoint() .
    45 
    44 
    46 
    45 
    47 public class MenuDragMouseEventAbsoluteCoordsTest extends Applet implements MouseListener
    46 public class MenuDragMouseEventAbsoluteCoordsTest implements MouseListener
    48 {
    47 {
    49     Frame frame = new Frame("MenuDragMouseEvent Test Frame");
    48     Frame frame = new Frame("MenuDragMouseEvent Test Frame");
    50 
    49 
    51     Point mousePositionOnScreen = new Point(200, 200);
    50     Point mousePositionOnScreen = new Point(200, 200);
    52     Point mousePosition = new Point(100, 100);
    51     Point mousePosition = new Point(100, 100);
       
    52 
       
    53     public static void main(String[] args) {
       
    54         MenuDragMouseEventAbsoluteCoordsTest app = new MenuDragMouseEventAbsoluteCoordsTest();
       
    55         app.init();
       
    56         app.start();
       
    57     }
       
    58 
    53     public void init()
    59     public void init()
    54     {
    60     {
    55         frame.addMouseListener(this);
    61         frame.addMouseListener(this);
    56     }//End  init()
    62     }//End  init()
    57 
    63 
    58     public void start ()
    64     public void start ()
    59     {
    65     {
    60         //Get things going.  Request focus, set size, et cetera
    66         //Get things going.  Request focus, set size, et cetera
    61         frame.setSize (200,200);
    67         frame.setSize (200,200);
    62         frame.setVisible(true);
    68         frame.setVisible(true);
    63         validate();
       
    64 
    69 
    65         try {
    70         try {
    66             Util.waitForIdle(new Robot());
    71             Util.waitForIdle(new Robot());
    67         }catch (Exception e){
    72         }catch (Exception e){
    68             throw new RuntimeException("Test failed.", e);
    73             throw new RuntimeException("Test failed.", e);