src/java.desktop/share/classes/java/awt/MouseInfo.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2003, 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. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2003, 2015, 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. Oracle designates this
*** 24,33 **** --- 24,34 ---- */ package java.awt; import sun.awt.AWTPermissions; + import sun.awt.ComponentFactory; /** * <code>MouseInfo</code> provides methods for getting information about the mouse, * such as mouse pointer location and the number of mouse buttons. *
*** 78,89 **** SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(AWTPermissions.WATCH_MOUSE_PERMISSION); } Point point = new Point(0, 0); ! int deviceNum = Toolkit.getDefaultToolkit().getMouseInfoPeer().fillPointWithCoords(point); GraphicsDevice[] gds = GraphicsEnvironment.getLocalGraphicsEnvironment(). getScreenDevices(); PointerInfo retval = null; if (areScreenDevicesIndependent(gds)) { retval = new PointerInfo(gds[deviceNum], point); --- 79,95 ---- SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(AWTPermissions.WATCH_MOUSE_PERMISSION); } + Toolkit toolkit = Toolkit.getDefaultToolkit(); Point point = new Point(0, 0); ! int deviceNum = 0; ! if (toolkit instanceof ComponentFactory) { ! deviceNum = ((ComponentFactory) toolkit).getMouseInfoPeer().fillPointWithCoords(point); ! } ! GraphicsDevice[] gds = GraphicsEnvironment.getLocalGraphicsEnvironment(). getScreenDevices(); PointerInfo retval = null; if (areScreenDevicesIndependent(gds)) { retval = new PointerInfo(gds[deviceNum], point);