< prev index next >

test/jdk/java/awt/event/MouseEvent/FrameMouseEventAbsoluteCoordsTest/FrameMouseEventAbsoluteCoordsTest.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 20,68 **** * or visit www.oracle.com if you need additional information or have any * questions. */ /* ! test @bug 4992908 @summary Need way to get location of MouseEvent in screen coordinates (Unit-test) ! @author Andrei.Dmitriev area=event ! @run applet FrameMouseEventAbsoluteCoordsTest.html */ - import java.applet.Applet; import java.awt.*; import java.awt.event.*; import test.java.awt.regtesthelpers.Util; // Part II // Create Frame. // Click on this frame. // verify that our MouseEvent contain correct xAbs, yAbs values ! public class FrameMouseEventAbsoluteCoordsTest extends Applet implements MouseListener { Robot robot; Frame frame = new Frame("MouseEvent Test Frame II"); Button button = new Button("Just Button"); Point mousePositionAbsolute; Point mousePosition; public void init() { - - this.setLayout (new BorderLayout ()); button.addMouseListener(this); frame.add(button); frame.pack(); }//End init() public void start () { - setSize (200,200); frame.setVisible(true); - validate(); Util.waitForIdle(robot); try { robot = new Robot(); robot.setAutoWaitForIdle(true); --- 20,72 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ /* ! @test ! @key headful @bug 4992908 @summary Need way to get location of MouseEvent in screen coordinates (Unit-test) ! @library ../../../regtesthelpers ! @build Util ! @run main FrameMouseEventAbsoluteCoordsTest */ import java.awt.*; import java.awt.event.*; import test.java.awt.regtesthelpers.Util; // Part II // Create Frame. // Click on this frame. // verify that our MouseEvent contain correct xAbs, yAbs values ! public class FrameMouseEventAbsoluteCoordsTest implements MouseListener { Robot robot; Frame frame = new Frame("MouseEvent Test Frame II"); Button button = new Button("Just Button"); Point mousePositionAbsolute; Point mousePosition; + public static void main(final String[] args) { + FrameMouseEventAbsoluteCoordsTest app = new FrameMouseEventAbsoluteCoordsTest(); + app.init(); + app.start(); + } + public void init() { button.addMouseListener(this); frame.add(button); frame.pack(); + frame.setLocationRelativeTo(null); }//End init() public void start () { frame.setVisible(true); Util.waitForIdle(robot); try { robot = new Robot(); robot.setAutoWaitForIdle(true);
< prev index next >