当前位置: 首页>>代码示例>>Java>>正文


Java NativeMouseListener类代码示例

本文整理汇总了Java中org.jnativehook.mouse.NativeMouseListener的典型用法代码示例。如果您正苦于以下问题:Java NativeMouseListener类的具体用法?Java NativeMouseListener怎么用?Java NativeMouseListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NativeMouseListener类属于org.jnativehook.mouse包,在下文中一共展示了NativeMouseListener类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processButtonEvent

import org.jnativehook.mouse.NativeMouseListener; //导入依赖的package包/类
/**
 * 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;
		}
	}
}
 
开发者ID:kwhat,项目名称:jnativehook,代码行数:29,代码来源:GlobalScreen.java

示例2: testAddNativeMouseListener

import org.jnativehook.mouse.NativeMouseListener; //导入依赖的package包/类
/**
 * Test of addNativeMouseListener method, of class GlobalScreen.
 */
@Test
public void testAddNativeMouseListener() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
	System.out.println("addNativeMouseListener");

	NativeMouseListener listener = new NativeMouseInputListenerImpl();
	GlobalScreen.addNativeMouseListener(listener);

	Field eventListeners = GlobalScreen.class.getDeclaredField("eventListeners");
	eventListeners.setAccessible(true);
	EventListenerList listeners = (EventListenerList) eventListeners.get(GlobalScreen.class);

	boolean found = false;
	NativeMouseListener[] nativeKeyListeners = listeners.getListeners(NativeMouseListener.class);
	for (int i = 0; i < nativeKeyListeners.length && !found; i++) {
		if (nativeKeyListeners[i].equals(listener)) {
			found = true;
		}
	}

	if (!found) {
		fail("Could not find the listener after it was added!");
	}

	GlobalScreen.removeNativeMouseListener(listener);
}
 
开发者ID:kwhat,项目名称:jnativehook,代码行数:29,代码来源:GlobalScreenTest.java

示例3: testRemoveNativeMouseListener

import org.jnativehook.mouse.NativeMouseListener; //导入依赖的package包/类
/**
 * Test of removeNativeMouseListener method, of class GlobalScreen.
 */
@Test
public void testRemoveNativeMouseListener() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
	System.out.println("removeNativeMouseListener");

	NativeMouseListener listener = new NativeMouseInputListenerImpl();
	GlobalScreen.addNativeMouseListener(listener);
	GlobalScreen.removeNativeMouseListener(listener);

	Field eventListeners = GlobalScreen.class.getDeclaredField("eventListeners");
	eventListeners.setAccessible(true);
	EventListenerList listeners = (EventListenerList) eventListeners.get(GlobalScreen.class);

	boolean found = false;
	NativeMouseListener[] nativeKeyListeners = listeners.getListeners(NativeMouseListener.class);
	for (int i = 0; i < nativeKeyListeners.length && !found; i++) {
		if (nativeKeyListeners[i].equals(listener)) {
			found = true;
		}
	}

	if (found) {
		fail("Found the listener after it was removed!");
	}
}
 
开发者ID:kwhat,项目名称:jnativehook,代码行数:28,代码来源:GlobalScreenTest.java

示例4: processMouseEvent

import org.jnativehook.mouse.NativeMouseListener; //导入依赖的package包/类
/**
 * 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;
		}
	}
}
 
开发者ID:Hual,项目名称:UploadR,代码行数:45,代码来源:GlobalScreen.java

示例5: addNativeMouseListener

import org.jnativehook.mouse.NativeMouseListener; //导入依赖的package包/类
/**
 * Adds the specified native mouse listener to receive mouse events from the
 * native system. If listener is null, no exception is thrown and no action
 * is performed.
 *
 * @param listener a native mouse listener object
 */
public static void addNativeMouseListener(NativeMouseListener listener) {
	if (listener != null) {
		eventListeners.add(NativeMouseListener.class, listener);
	}
}
 
开发者ID:kwhat,项目名称:jnativehook,代码行数:13,代码来源:GlobalScreen.java

示例6: removeNativeMouseListener

import org.jnativehook.mouse.NativeMouseListener; //导入依赖的package包/类
/**
 * Removes the specified native mouse listener so that it no longer receives
 * mouse events from the native system. This method performs no function if
 * the listener specified by the argument was not previously added.  If
 * listener is null, no exception is thrown and no action is performed.
 *
 * @param listener a native mouse listener object
 */
public static void removeNativeMouseListener(NativeMouseListener listener) {
	if (listener != null) {
		eventListeners.remove(NativeMouseListener.class, listener);
	}
}
 
开发者ID:kwhat,项目名称:jnativehook,代码行数:14,代码来源:GlobalScreen.java

示例7: addNativeMouseListener

import org.jnativehook.mouse.NativeMouseListener; //导入依赖的package包/类
/**
 * Adds the specified native mouse listener to receive mouse events from the
 * native system. If listener is null, no exception is thrown and no action
 * is performed.
 *
 * @param listener a native mouse listener object
 */
public void addNativeMouseListener(NativeMouseListener listener) {
	if (listener != null) {
		eventListeners.add(NativeMouseListener.class, listener);
	}
}
 
开发者ID:Hual,项目名称:UploadR,代码行数:13,代码来源:GlobalScreen.java

示例8: removeNativeMouseListener

import org.jnativehook.mouse.NativeMouseListener; //导入依赖的package包/类
/**
 * Removes the specified native mouse listener so that it no longer receives
 * mouse events from the native system. This method performs no function if
 * the listener specified by the argument was not previously added.  If
 * listener is null, no exception is thrown and no action is performed.
 *
 * @param listener a native mouse listener object
 */
public void removeNativeMouseListener(NativeMouseListener listener) {
	if (listener != null) {
		eventListeners.remove(NativeMouseListener.class, listener);
	}
}
 
开发者ID:Hual,项目名称:UploadR,代码行数:14,代码来源:GlobalScreen.java


注:本文中的org.jnativehook.mouse.NativeMouseListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。