< prev index next >

test/java/awt/Robot/HiDPIMouseClick/HiDPIRobotMouseClick.java

Print this page
rev 17565 : 8185500: [TESTBUG] Add keywords headful/printer in java/awt and javax tests.
Summary: Add new keyword 'printer'. Some minor test fixes to show headless exception. Add some @requires windows.
Reviewed-by: serb, mbaesken
   1 /*
   2  * Copyright (c) 2015, 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.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.awt.Frame;
  25 import java.awt.Rectangle;
  26 import java.awt.Robot;
  27 import java.awt.event.InputEvent;
  28 import java.awt.event.MouseAdapter;
  29 import java.awt.event.MouseEvent;
  30 import javax.swing.UIManager;
  31 
  32 /* @test


  33  * @bug 8073320
  34  * @summary  Windows HiDPI support
  35  * @author Alexander Scherbatiy
  36  * @requires (os.family == "windows")
  37  * @run main/othervm -Dsun.java2d.win.uiScale=2 HiDPIRobotMouseClick
  38  */

  39 public class HiDPIRobotMouseClick {
  40 
  41     private static volatile int mouseX;
  42     private static volatile int mouseY;
  43 
  44     public static void main(String[] args) throws Exception {
  45 
  46         try {
  47             UIManager.setLookAndFeel(
  48                     "com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
  49         } catch (Exception e) {
  50             return;
  51         }
  52 
  53         Frame frame = new Frame();
  54         frame.setBounds(30, 20, 400, 300);
  55         frame.setUndecorated(true);
  56 
  57         frame.addMouseListener(new MouseAdapter() {
  58 


   1 /*
   2  * Copyright (c) 2015, 2017, 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.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.awt.Frame;
  25 import java.awt.Rectangle;
  26 import java.awt.Robot;
  27 import java.awt.event.InputEvent;
  28 import java.awt.event.MouseAdapter;
  29 import java.awt.event.MouseEvent;
  30 import javax.swing.UIManager;
  31 
  32 /**
  33  * @test
  34  * @key headful
  35  * @bug 8073320
  36  * @summary  Windows HiDPI support
  37  * @author Alexander Scherbatiy
  38  * @requires (os.family == "windows")
  39  * @run main/othervm -Dsun.java2d.win.uiScale=2 HiDPIRobotMouseClick
  40  */
  41 
  42 public class HiDPIRobotMouseClick {
  43 
  44     private static volatile int mouseX;
  45     private static volatile int mouseY;
  46 
  47     public static void main(String[] args) throws Exception {
  48 
  49         try {
  50             UIManager.setLookAndFeel(
  51                     "com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
  52         } catch (Exception e) {
  53             return;
  54         }
  55 
  56         Frame frame = new Frame();
  57         frame.setBounds(30, 20, 400, 300);
  58         frame.setUndecorated(true);
  59 
  60         frame.addMouseListener(new MouseAdapter() {
  61 


< prev index next >