Module com.github.kwhat.jnativehook
Class NativeHookDemo
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Window
-
- java.awt.Frame
-
- javax.swing.JFrame
-
- com.github.kwhat.jnativehook.example.NativeHookDemo
-
- All Implemented Interfaces:
NativeKeyListener
,NativeMouseInputListener
,NativeMouseListener
,NativeMouseMotionListener
,NativeMouseWheelListener
,ActionListener
,ItemListener
,WindowListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,RootPaneContainer
,WindowConstants
public class NativeHookDemo extends JFrame implements ActionListener, ItemListener, NativeKeyListener, NativeMouseInputListener, NativeMouseWheelListener, WindowListener
A demonstration of how to use the JNativeHook library.- Since:
- 1.0
- Version:
- 2.0
- Author:
- Alexander Barker (alex@1stleg.com)
- See Also:
GlobalScreen
,NativeKeyListener
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
-
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
-
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.Type
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
-
Fields inherited from class javax.swing.JFrame
accessibleContext, rootPane, rootPaneCheckingEnabled
-
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
-
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
-
-
Constructor Summary
Constructors Constructor Description NativeHookDemo()
Instantiates a new native hook demo.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(ActionEvent e)
void
itemStateChanged(ItemEvent e)
static void
main(String[] args)
The demo project entry point.void
nativeKeyPressed(NativeKeyEvent e)
Invoked when a key has been pressed.void
nativeKeyReleased(NativeKeyEvent e)
Invoked when a key has been released.void
nativeKeyTyped(NativeKeyEvent e)
Invoked when a key has been typed.void
nativeMouseClicked(NativeMouseEvent e)
Invoked when a mouse button has been clicked (pressed and released) without being moved.void
nativeMouseDragged(NativeMouseEvent e)
Invoked when the mouse has been moved while a button is depressed.void
nativeMouseMoved(NativeMouseEvent e)
Invoked when the mouse has been moved.void
nativeMousePressed(NativeMouseEvent e)
Invoked when a mouse button has been pressedvoid
nativeMouseReleased(NativeMouseEvent e)
Invoked when a mouse button has been releasedvoid
nativeMouseWheelMoved(NativeMouseWheelEvent e)
Invoked when the mouse wheel is rotated.void
windowActivated(WindowEvent e)
Unimplementedvoid
windowClosed(WindowEvent e)
Finalize and exit the program.void
windowClosing(WindowEvent e)
Unimplementedvoid
windowDeactivated(WindowEvent e)
Unimplementedvoid
windowDeiconified(WindowEvent e)
Unimplementedvoid
windowIconified(WindowEvent e)
Unimplementedvoid
windowOpened(WindowEvent e)
Display information about the native keyboard and mouse along with any errors that may have occurred.-
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
-
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
-
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
-
-
-
-
Method Detail
-
actionPerformed
public void actionPerformed(ActionEvent e)
- Specified by:
actionPerformed
in interfaceActionListener
- See Also:
ActionListener.actionPerformed(java.awt.event.ActionEvent)
-
itemStateChanged
public void itemStateChanged(ItemEvent e)
- Specified by:
itemStateChanged
in interfaceItemListener
- See Also:
ItemListener.itemStateChanged(java.awt.event.ItemEvent)
-
nativeKeyPressed
public void nativeKeyPressed(NativeKeyEvent e)
Description copied from interface:NativeKeyListener
Invoked when a key has been pressed.- Specified by:
nativeKeyPressed
in interfaceNativeKeyListener
- Parameters:
e
- the native key event.- See Also:
NativeKeyListener.nativeKeyPressed(NativeKeyEvent)
-
nativeKeyReleased
public void nativeKeyReleased(NativeKeyEvent e)
Description copied from interface:NativeKeyListener
Invoked when a key has been released.- Specified by:
nativeKeyReleased
in interfaceNativeKeyListener
- Parameters:
e
- the native key event.- See Also:
NativeKeyListener.nativeKeyReleased(NativeKeyEvent)
-
nativeKeyTyped
public void nativeKeyTyped(NativeKeyEvent e)
Description copied from interface:NativeKeyListener
Invoked when a key has been typed.- Specified by:
nativeKeyTyped
in interfaceNativeKeyListener
- Parameters:
e
- the native key event.- See Also:
NativeKeyListener.nativeKeyTyped(NativeKeyEvent)
-
nativeMouseClicked
public void nativeMouseClicked(NativeMouseEvent e)
Description copied from interface:NativeMouseListener
Invoked when a mouse button has been clicked (pressed and released) without being moved.- Specified by:
nativeMouseClicked
in interfaceNativeMouseListener
- Parameters:
e
- the native mouse event.- See Also:
NativeMouseListener.nativeMouseClicked(NativeMouseEvent)
-
nativeMousePressed
public void nativeMousePressed(NativeMouseEvent e)
Description copied from interface:NativeMouseListener
Invoked when a mouse button has been pressed- Specified by:
nativeMousePressed
in interfaceNativeMouseListener
- Parameters:
e
- the native mouse event.- See Also:
NativeMouseListener.nativeMousePressed(NativeMouseEvent)
-
nativeMouseReleased
public void nativeMouseReleased(NativeMouseEvent e)
Description copied from interface:NativeMouseListener
Invoked when a mouse button has been released- Specified by:
nativeMouseReleased
in interfaceNativeMouseListener
- Parameters:
e
- the native mouse event.- See Also:
NativeMouseListener.nativeMouseReleased(NativeMouseEvent)
-
nativeMouseMoved
public void nativeMouseMoved(NativeMouseEvent e)
Description copied from interface:NativeMouseMotionListener
Invoked when the mouse has been moved.- Specified by:
nativeMouseMoved
in interfaceNativeMouseMotionListener
- Parameters:
e
- the native mouse event.- See Also:
NativeMouseMotionListener.nativeMouseMoved(NativeMouseEvent)
-
nativeMouseDragged
public void nativeMouseDragged(NativeMouseEvent e)
Description copied from interface:NativeMouseMotionListener
Invoked when the mouse has been moved while a button is depressed.- Specified by:
nativeMouseDragged
in interfaceNativeMouseMotionListener
- Parameters:
e
- the native mouse event- See Also:
NativeMouseMotionListener.nativeMouseDragged(NativeMouseEvent)
-
nativeMouseWheelMoved
public void nativeMouseWheelMoved(NativeMouseWheelEvent e)
Description copied from interface:NativeMouseWheelListener
Invoked when the mouse wheel is rotated.- Specified by:
nativeMouseWheelMoved
in interfaceNativeMouseWheelListener
- Parameters:
e
- the native mouse wheel event.- See Also:
NativeMouseWheelListener.nativeMouseWheelMoved(NativeMouseWheelEvent)
-
windowActivated
public void windowActivated(WindowEvent e)
Unimplemented- Specified by:
windowActivated
in interfaceWindowListener
- See Also:
WindowListener.windowActivated(java.awt.event.WindowEvent)
-
windowClosing
public void windowClosing(WindowEvent e)
Unimplemented- Specified by:
windowClosing
in interfaceWindowListener
- See Also:
WindowListener.windowClosing(java.awt.event.WindowEvent)
-
windowDeactivated
public void windowDeactivated(WindowEvent e)
Unimplemented- Specified by:
windowDeactivated
in interfaceWindowListener
- See Also:
WindowListener.windowDeactivated(java.awt.event.WindowEvent)
-
windowDeiconified
public void windowDeiconified(WindowEvent e)
Unimplemented- Specified by:
windowDeiconified
in interfaceWindowListener
- See Also:
WindowListener.windowDeiconified(java.awt.event.WindowEvent)
-
windowIconified
public void windowIconified(WindowEvent e)
Unimplemented- Specified by:
windowIconified
in interfaceWindowListener
- See Also:
WindowListener.windowIconified(java.awt.event.WindowEvent)
-
windowOpened
public void windowOpened(WindowEvent e)
Display information about the native keyboard and mouse along with any errors that may have occurred.- Specified by:
windowOpened
in interfaceWindowListener
- See Also:
WindowListener.windowOpened(java.awt.event.WindowEvent)
-
windowClosed
public void windowClosed(WindowEvent e)
Finalize and exit the program.- Specified by:
windowClosed
in interfaceWindowListener
- See Also:
WindowListener.windowClosed(java.awt.event.WindowEvent)
-
main
public static void main(String[] args)
The demo project entry point.- Parameters:
args
- unused.
-
-