public class MouseInfo extends Object
MouseInfo提供了获取鼠标信息的方法,如鼠标指针位置和鼠标按钮数量。
| Modifier and Type | Method and Description |
|---|---|
static int |
getNumberOfButtons()
返回鼠标的按钮数量。
|
static PointerInfo |
getPointerInfo()
返回表示鼠标指针当前位置的
PointerInfo实例。
|
public static PointerInfo getPointerInfo() throws HeadlessException
PointerInfo鼠标指针当前位置的PointerInfo实例。
该GraphicsDevice存储在此PointerInfo包含鼠标指针。
用于鼠标位置的坐标系取决于GraphicsDevice是否是虚拟屏幕设备的一部分。
对于虚拟屏幕设备,坐标在虚拟坐标系中给出,否则它们在GraphicsDevice的坐标系中GraphicsDevice 。
有关虚拟屏幕设备的更多信息,请参阅GraphicsConfiguration 。
在没有鼠标的系统上,返回null 。
如果有安全管理器, checkPermission方法被称为与AWTPermission("watchMousePointer")创建和返回之前允许PointerInfo对象。 这可能会导致SecurityException 。
HeadlessException - 如果GraphicsEnvironment.isHeadless()返回true
SecurityException - 如果安全管理器存在,并且其
checkPermission方法不允许操作
GraphicsConfiguration , SecurityManager.checkPermission(java.security.Permission) , AWTPermission
public static int getNumberOfButtons()
throws HeadlessException
-1 。
HeadlessException - 如果GraphicsEnvironment.isHeadless()返回true
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.