本文整理汇总了Java中org.jnativehook.mouse.NativeMouseEvent.NATIVE_MOUSE_CLICKED属性的典型用法代码示例。如果您正苦于以下问题:Java NativeMouseEvent.NATIVE_MOUSE_CLICKED属性的具体用法?Java NativeMouseEvent.NATIVE_MOUSE_CLICKED怎么用?Java NativeMouseEvent.NATIVE_MOUSE_CLICKED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.jnativehook.mouse.NativeMouseEvent
的用法示例。
在下文中一共展示了NativeMouseEvent.NATIVE_MOUSE_CLICKED属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
public void run() {
if (event instanceof NativeKeyEvent) {
processKeyEvent((NativeKeyEvent) event);
}
else if (event instanceof NativeMouseWheelEvent) {
processMouseWheelEvent((NativeMouseWheelEvent) event);
}
else if (event instanceof NativeMouseEvent) {
switch (event.getID()) {
case NativeMouseEvent.NATIVE_MOUSE_PRESSED:
case NativeMouseEvent.NATIVE_MOUSE_CLICKED:
case NativeMouseEvent.NATIVE_MOUSE_RELEASED:
processButtonEvent((NativeMouseEvent) event);
break;
case NativeMouseEvent.NATIVE_MOUSE_MOVED:
case NativeMouseEvent.NATIVE_MOUSE_DRAGGED:
processMouseEvent((NativeMouseEvent) event);
break;
}
}
else if (event instanceof NativeMouseWheelEvent) {
processMouseWheelEvent((NativeMouseWheelEvent) event);
}
}
示例2: processButtonEvent
/**
* Processes native mouse button events by dispatching them to all registered
* <code>NativeMouseListener</code> objects.
*
* @param e the <code>NativeMouseEvent</code> to dispatch.
* @see NativeMouseEvent
* @see NativeMouseListener
* @see #addNativeMouseListener(NativeMouseListener)
*/
private void processButtonEvent(NativeMouseEvent e) {
NativeMouseListener[] listeners = eventListeners.getListeners(NativeMouseListener.class);
for (int i = 0; i < listeners.length; i++) {
switch (e.getID()) {
case NativeMouseEvent.NATIVE_MOUSE_CLICKED:
listeners[i].nativeMouseClicked(e);
break;
case NativeMouseEvent.NATIVE_MOUSE_PRESSED:
listeners[i].nativeMousePressed(e);
break;
case NativeMouseEvent.NATIVE_MOUSE_RELEASED:
listeners[i].nativeMouseReleased(e);
break;
}
}
}
示例3: testProcessMouseEvent
/**
* Test of processMouseEvent method, of class GlobalScreen.
*/
@Test
public void testProcessMouseEvent() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, InterruptedException {
System.out.println("processMouseEvent");
// Setup and event listener.
NativeMouseInputListenerImpl listener = new NativeMouseInputListenerImpl();
GlobalScreen.addNativeMouseListener(listener);
// Dispatch a mouse event and check to see if it was sent.
NativeMouseEvent event = new NativeMouseEvent(
NativeMouseEvent.NATIVE_MOUSE_CLICKED,
0x00, // Modifiers
50, // X
75, // Y
1, // Click Count
NativeMouseEvent.BUTTON1);
synchronized (listener) {
GlobalScreen.dispatchEvent(event);
listener.wait(3000);
assertEquals(event, listener.getLastEvent());
}
GlobalScreen.removeNativeMouseListener(listener);
}
示例4: nativeMouseClicked
public void nativeMouseClicked(NativeMouseEvent e) {
System.out.println("Received " + e.paramString());
if (e.getID() != NativeMouseEvent.NATIVE_MOUSE_CLICKED) {
throw new IllegalArgumentException("Invalid event type received for nativeMouseClicked!");
}
lastEvent = e;
synchronized(this) {
this.notifyAll();
}
}
示例5: processMouseEvent
/**
* Processes native mouse events by dispatching them to all registered
* <code>NativeMouseListener</code> objects.
*
* @param e the <code>NativeMouseEvent</code> to dispatch.
* @see NativeMouseEvent
* @see NativeMouseListener
* @see #addNativeMouseListener(NativeMouseListener)
*/
protected void processMouseEvent(NativeMouseEvent e) {
int id = e.getID();
EventListener[] listeners;
if (id == NativeMouseEvent.NATIVE_MOUSE_MOVED || id == NativeMouseEvent.NATIVE_MOUSE_DRAGGED) {
listeners = eventListeners.getListeners(NativeMouseMotionListener.class);
}
else {
listeners = eventListeners.getListeners(NativeMouseListener.class);
}
for (int i = 0; i < listeners.length; i++) {
switch (id) {
case NativeMouseEvent.NATIVE_MOUSE_CLICKED:
((NativeMouseListener) listeners[i]).nativeMouseClicked(e);
break;
case NativeMouseEvent.NATIVE_MOUSE_PRESSED:
((NativeMouseListener) listeners[i]).nativeMousePressed(e);
break;
case NativeMouseEvent.NATIVE_MOUSE_RELEASED:
((NativeMouseListener) listeners[i]).nativeMouseReleased(e);
break;
case NativeMouseEvent.NATIVE_MOUSE_MOVED:
((NativeMouseMotionListener) listeners[i]).nativeMouseMoved(e);
break;
case NativeMouseEvent.NATIVE_MOUSE_DRAGGED:
((NativeMouseMotionListener) listeners[i]).nativeMouseDragged(e);
break;
}
}
}
示例6: testDispatchEvent
/**
* Test of dispatchEvent method, of class GlobalScreen.
*/
@Test
public void testDispatchEvent() throws InterruptedException, NativeHookException {
System.out.println("dispatchEvent");
// Setup and event listener.
NativeKeyListenerImpl keyListener = new NativeKeyListenerImpl();
GlobalScreen.addNativeKeyListener(keyListener);
NativeMouseInputListenerImpl mouseListener = new NativeMouseInputListenerImpl();
GlobalScreen.addNativeMouseListener(mouseListener);
NativeMouseWheelListenerImpl wheelListener = new NativeMouseWheelListenerImpl();
GlobalScreen.addNativeMouseWheelListener(wheelListener);
// Make sure the native thread is running!
GlobalScreen.registerNativeHook();
// Dispatch a key event and check to see if it was sent.
NativeKeyEvent keyEvent = new NativeKeyEvent(
NativeKeyEvent.NATIVE_KEY_PRESSED,
0x00, // Modifiers
0x41, // Raw Code
NativeKeyEvent.VC_A,
NativeKeyEvent.CHAR_UNDEFINED,
NativeKeyEvent.KEY_LOCATION_STANDARD);
synchronized (keyListener) {
GlobalScreen.dispatchEvent(keyEvent);
keyListener.wait(3000);
assertEquals(keyEvent, keyListener.getLastEvent());
}
// Dispatch a mouse event and check to see if it was sent.
NativeMouseEvent mouseEvent = new NativeMouseEvent(
NativeMouseEvent.NATIVE_MOUSE_CLICKED,
0x00, // Modifiers
50, // X
75, // Y
1, // Click Count
NativeMouseEvent.BUTTON1);
synchronized (mouseListener) {
GlobalScreen.dispatchEvent(mouseEvent);
mouseListener.wait(3000);
assertEquals(mouseEvent, mouseListener.getLastEvent());
}
// Dispatch a mouse event and check to see if it was sent.
NativeMouseWheelEvent wheelEvent = new NativeMouseWheelEvent(
NativeMouseEvent.NATIVE_MOUSE_WHEEL,
0x00, // Modifiers
50, // X
75, // Y
1, // Click Count
NativeMouseWheelEvent.WHEEL_UNIT_SCROLL,
3, // Scroll Amount
-1); // Wheel Rotation
synchronized (wheelListener) {
GlobalScreen.dispatchEvent(wheelEvent);
wheelListener.wait(3000);
assertEquals(wheelEvent, wheelListener.getLastEvent());
}
// Stop the native thread.
GlobalScreen.unregisterNativeHook();
// Remove all added listeners.
GlobalScreen.removeNativeKeyListener(keyListener);
GlobalScreen.removeNativeMouseListener(mouseListener);
GlobalScreen.removeNativeMouseWheelListener(wheelListener);
}