APIdia Launch Partner
Top Description Constructors Methods
java.awt

public Class MouseInfo

extends Object
Class Inheritance
Imports
sun.awt.ComponentFactory

MouseInfo provides methods for getting information about the mouse, such as mouse pointer location and the number of mouse buttons.
Author
Roman Poborchiy
Since
1.5

Constructor Summary

AccessConstructor and Description
private
MouseInfo()

Private constructor to prevent instantiation.

Method Summary

Modifier and TypeMethod and Description
private static boolean
public static int

Returns:

number of buttons on the mouse
getNumberOfButtons
()

Returns the number of buttons on the mouse.

public static PointerInfo

Returns:

location of the mouse pointer
getPointerInfo
()

Returns a PointerInfo instance that represents the current location of the mouse pointer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MouseInfoback to summary
private MouseInfo()

Private constructor to prevent instantiation.

Method Detail

areScreenDevicesIndependentback to summary
private static boolean areScreenDevicesIndependent(GraphicsDevice[] gds)
getNumberOfButtonsback to summary
public static int getNumberOfButtons() throws HeadlessException

Returns the number of buttons on the mouse. On systems without a mouse, returns -1. The number of buttons is obtained from the AWT Toolkit by requesting the "awt.mouse.numButtons" desktop property which is set by the underlying native platform.

Returns:int

number of buttons on the mouse

Exceptions
HeadlessException:
if GraphicsEnvironment.isHeadless() returns true
Since
1.5
See Also
Toolkit#getDesktopProperty
getPointerInfoback to summary
public static PointerInfo getPointerInfo() throws HeadlessException

Returns a PointerInfo instance that represents the current location of the mouse pointer. The GraphicsDevice stored in this PointerInfo contains the mouse pointer. The coordinate system used for the mouse position depends on whether or not the GraphicsDevice is part of a virtual screen device. For virtual screen devices, the coordinates are given in the virtual coordinate system, otherwise they are returned in the coordinate system of the GraphicsDevice. See GraphicsConfiguration for more information about the virtual screen devices. On systems without a mouse, returns null.

Returns:PointerInfo

location of the mouse pointer

Exceptions
HeadlessException:
if GraphicsEnvironment.isHeadless() returns true
Since
1.5
See Also
GraphicsConfiguration