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

Print this page




  59      * is called with an <code>AWTPermission("watchMousePointer")</code>
  60      * permission before creating and returning a <code>PointerInfo</code>
  61      * object. This may result in a <code>SecurityException</code>.
  62      *
  63      * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true
  64      * @exception SecurityException if a security manager exists and its
  65      *            <code>checkPermission</code> method doesn't allow the operation
  66      * @see       GraphicsConfiguration
  67      * @see       SecurityManager#checkPermission
  68      * @see       java.awt.AWTPermission
  69      * @return    location of the mouse pointer
  70      * @since     1.5
  71      */
  72     public static PointerInfo getPointerInfo() throws HeadlessException {
  73         if (GraphicsEnvironment.isHeadless()) {
  74             throw new HeadlessException();
  75         }
  76 
  77         SecurityManager security = System.getSecurityManager();
  78         if (security != null) {
  79             security.checkPermission(SecurityConstants.WATCH_MOUSE_PERMISSION);
  80         }
  81 
  82         Point point = new Point(0, 0);
  83         int deviceNum = Toolkit.getDefaultToolkit().getMouseInfoPeer().fillPointWithCoords(point);
  84         GraphicsDevice[] gds = GraphicsEnvironment.getLocalGraphicsEnvironment().
  85                                    getScreenDevices();
  86         PointerInfo retval = null;
  87         if (areScreenDevicesIndependent(gds)) {
  88             retval = new PointerInfo(gds[deviceNum], point);
  89         } else {
  90             for (int i = 0; i < gds.length; i++) {
  91                 GraphicsConfiguration gc = gds[i].getDefaultConfiguration();
  92                 Rectangle bounds = gc.getBounds();
  93                 if (bounds.contains(point)) {
  94                     retval = new PointerInfo(gds[i], point);
  95                 }
  96             }
  97         }
  98 
  99         return retval;




  59      * is called with an <code>AWTPermission("watchMousePointer")</code>
  60      * permission before creating and returning a <code>PointerInfo</code>
  61      * object. This may result in a <code>SecurityException</code>.
  62      *
  63      * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true
  64      * @exception SecurityException if a security manager exists and its
  65      *            <code>checkPermission</code> method doesn't allow the operation
  66      * @see       GraphicsConfiguration
  67      * @see       SecurityManager#checkPermission
  68      * @see       java.awt.AWTPermission
  69      * @return    location of the mouse pointer
  70      * @since     1.5
  71      */
  72     public static PointerInfo getPointerInfo() throws HeadlessException {
  73         if (GraphicsEnvironment.isHeadless()) {
  74             throw new HeadlessException();
  75         }
  76 
  77         SecurityManager security = System.getSecurityManager();
  78         if (security != null) {
  79             security.checkPermission(SecurityConstants.AWT.WATCH_MOUSE_PERMISSION);
  80         }
  81 
  82         Point point = new Point(0, 0);
  83         int deviceNum = Toolkit.getDefaultToolkit().getMouseInfoPeer().fillPointWithCoords(point);
  84         GraphicsDevice[] gds = GraphicsEnvironment.getLocalGraphicsEnvironment().
  85                                    getScreenDevices();
  86         PointerInfo retval = null;
  87         if (areScreenDevicesIndependent(gds)) {
  88             retval = new PointerInfo(gds[deviceNum], point);
  89         } else {
  90             for (int i = 0; i < gds.length; i++) {
  91                 GraphicsConfiguration gc = gds[i].getDefaultConfiguration();
  92                 Rectangle bounds = gc.getBounds();
  93                 if (bounds.contains(point)) {
  94                     retval = new PointerInfo(gds[i], point);
  95                 }
  96             }
  97         }
  98 
  99         return retval;