public class GlobalScreen extends Object
This class also handles the loading, unpacking and communication with the native library. That includes registering and unregistering the native hook with the underlying operating system and adding global keyboard and mouse listeners.
| Modifier and Type | Method and Description |
|---|---|
void |
addNativeKeyListener(NativeKeyListener listener)
Adds the specified native key listener to receive key events from the
native system.
|
void |
addNativeMouseListener(NativeMouseListener listener)
Adds the specified native mouse listener to receive mouse events from the
native system.
|
void |
addNativeMouseMotionListener(NativeMouseMotionListener listener)
Adds the specified native mouse motion listener to receive mouse motion
events from the native system.
|
void |
addNativeMouseWheelListener(NativeMouseWheelListener listener)
Adds the specified native mouse wheel listener to receive mouse wheel
events from the native system.
|
void |
dispatchEvent(NativeInputEvent e)
Dispatches an event to the appropriate processor.
|
protected void |
finalize()
A destructor that will perform native cleanup by calling the
unregisterNativeHook() method. |
static GlobalScreen |
getInstance()
Returns the singleton instance of
GlobalScreen. |
static boolean |
isNativeHookRegistered()
Returns
true if the native hook is currently registered. |
protected static void |
loadNativeLibrary()
Perform procedures to interface with the native library.
|
protected void |
processKeyEvent(NativeKeyEvent e)
Processes native key events by dispatching them to all registered
NativeKeyListener objects. |
protected void |
processMouseEvent(NativeMouseEvent e)
Processes native mouse events by dispatching them to all registered
NativeMouseListener objects. |
protected void |
processMouseWheelEvent(NativeMouseWheelEvent e)
Processes native mouse wheel events by dispatching them to all registered
NativeMouseWheelListener objects. |
static void |
registerNativeHook()
Enable the native hook if it is not currently running.
|
void |
removeNativeKeyListener(NativeKeyListener listener)
Removes the specified native key listener so that it no longer receives
key events from the native system.
|
void |
removeNativeMouseListener(NativeMouseListener listener)
Removes the specified native mouse listener so that it no longer receives
mouse events from the native system.
|
void |
removeNativeMouseMotionListener(NativeMouseMotionListener listener)
Removes the specified native mouse motion listener so that it no longer
receives mouse motion events from the native system.
|
void |
removeNativeMouseWheelListener(NativeMouseWheelListener listener)
Removes the specified native mouse wheel listener so that it no longer
receives mouse wheel events from the native system.
|
protected void |
startEventDispatcher()
Initialize a local executor service for event delivery.
|
protected void |
stopEventDispatcher()
Shutdown the local executor service for event delivery.
|
protected static void |
unloadNativeLibrary()
Perform procedures to cleanup the native library.
|
static void |
unregisterNativeHook()
Disable the native hook if it is currently registered.
|
protected void finalize()
throws Throwable
unregisterNativeHook() method. This method will not run until the
class is garbage collected.finalize in class ObjectThrowable - a NativeHookException raised by calling
unloadNativeLibrary()Object.finalize()public static GlobalScreen getInstance()
GlobalScreen.GlobalScreenpublic void addNativeKeyListener(NativeKeyListener listener)
listener - a native key listener objectpublic void removeNativeKeyListener(NativeKeyListener listener)
listener - a native key listener objectpublic void addNativeMouseListener(NativeMouseListener listener)
listener - a native mouse listener objectpublic void removeNativeMouseListener(NativeMouseListener listener)
listener - a native mouse listener objectpublic void addNativeMouseMotionListener(NativeMouseMotionListener listener)
listener - a native mouse motion listener objectpublic void removeNativeMouseMotionListener(NativeMouseMotionListener listener)
listener - a native mouse motion listener objectpublic void addNativeMouseWheelListener(NativeMouseWheelListener listener)
listener - a native mouse wheel listener objectpublic void removeNativeMouseWheelListener(NativeMouseWheelListener listener)
listener - a native mouse wheel listener objectpublic static void registerNativeHook()
throws NativeHookException
Note: This method will throw a NativeHookException
if specific operating system features are unavailable or disabled.
For example: Access for assistive devices is unchecked in the Universal
Access section of the System Preferences on Apple's OS X platform or
Load "record" is missing for the xorg.conf file on
Unix/Linux/Solaris platforms.
NativeHookException - problem registering the native hook with
the underlying operating system.public static void unregisterNativeHook()
public static boolean isNativeHookRegistered()
true if the native hook is currently registered.public final void dispatchEvent(NativeInputEvent e)
e - the NativeInputEvent to dispatch.protected void processKeyEvent(NativeKeyEvent e)
NativeKeyListener objects.e - the NativeKeyEvent to dispatch.NativeKeyEvent,
NativeKeyListener,
addNativeKeyListener(NativeKeyListener)protected void processMouseEvent(NativeMouseEvent e)
NativeMouseListener objects.e - the NativeMouseEvent to dispatch.NativeMouseEvent,
NativeMouseListener,
addNativeMouseListener(NativeMouseListener)protected void processMouseWheelEvent(NativeMouseWheelEvent e)
NativeMouseWheelListener objects.e - The NativeMouseWheelEvent to dispatch.NativeMouseWheelEvent,
NativeMouseWheelListener,
addNativeMouseWheelListener(NativeMouseWheelListener)protected void startEventDispatcher()
protected void stopEventDispatcher()
protected static void loadNativeLibrary()
protected static void unloadNativeLibrary()
Copyright © 2006-2017 ${project.vendor}. All Rights Received.