當前位置: 首頁>>代碼示例>>Java>>正文


Java NativeKeyEvent.getID方法代碼示例

本文整理匯總了Java中org.jnativehook.keyboard.NativeKeyEvent.getID方法的典型用法代碼示例。如果您正苦於以下問題:Java NativeKeyEvent.getID方法的具體用法?Java NativeKeyEvent.getID怎麽用?Java NativeKeyEvent.getID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jnativehook.keyboard.NativeKeyEvent的用法示例。


在下文中一共展示了NativeKeyEvent.getID方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: nativeKeyPressed

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
public void nativeKeyPressed(NativeKeyEvent e) {
	System.out.println("Received " + e.paramString());

	if (e.getID() != NativeKeyEvent.NATIVE_KEY_PRESSED) {
		fail("Invalid event type received for nativeKeyPressed!");
	}

	lastEvent = e;

	synchronized(this) {
		this.notifyAll();
	}

	try {
		Field f = NativeInputEvent.class.getDeclaredField("reserved");
		f.setAccessible(true);
		f.setShort(e, (short) 0x01);
	}
	catch (Exception e1) {
		e1.printStackTrace();
	}
}
 
開發者ID:kwhat,項目名稱:jnativehook,代碼行數:23,代碼來源:NativeKeyListenerImpl.java

示例2: nativeKeyReleased

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
public void nativeKeyReleased(NativeKeyEvent e) {
	System.out.println("Received " + e.paramString());

	if (e.getID() != NativeKeyEvent.NATIVE_KEY_RELEASED) {
		fail("Invalid event type received for nativeKeyPressed!");
	}

	lastEvent = e;

	synchronized(this) {
		this.notifyAll();
	}

	try {
		Field f = NativeInputEvent.class.getDeclaredField("reserved");
		f.setAccessible(true);
		f.setShort(e, (short) 0x01);
	}
	catch (Exception e1) {
		e1.printStackTrace();
	}
}
 
開發者ID:kwhat,項目名稱:jnativehook,代碼行數:23,代碼來源:NativeKeyListenerImpl.java

示例3: nativeKeyTyped

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
public void nativeKeyTyped(NativeKeyEvent e) {
	System.out.println("Received " + e.paramString());

	if (e.getID() != NativeKeyEvent.NATIVE_KEY_TYPED) {
		fail("Invalid event type received for nativeKeyPressed!");
	}

	lastEvent = e;

	synchronized(this) {
		this.notifyAll();
	}

	try {
		Field f = NativeInputEvent.class.getDeclaredField("reserved");
		f.setAccessible(true);
		f.setShort(e, (short) 0x01);
	}
	catch (Exception e1) {
		e1.printStackTrace();
	}
}
 
開發者ID:kwhat,項目名稱:jnativehook,代碼行數:23,代碼來源:NativeKeyListenerImpl.java

示例4: processKeyEvent

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
/**
 * Processes native key events by dispatching them to all registered
 * <code>NativeKeyListener</code> objects.
 *
 * @param e the <code>NativeKeyEvent</code> to dispatch.
 * @see NativeKeyEvent
 * @see NativeKeyListener
 * @see #addNativeKeyListener(NativeKeyListener)
 */
protected void processKeyEvent(NativeKeyEvent e) {
	int id = e.getID();
	EventListener[] listeners = eventListeners.getListeners(NativeKeyListener.class);

	for (int i = 0; i < listeners.length; i++) {
		switch (id) {
			case NativeKeyEvent.NATIVE_KEY_PRESSED:
				((NativeKeyListener) listeners[i]).nativeKeyPressed(e);
				break;

			case NativeKeyEvent.NATIVE_KEY_TYPED:
				((NativeKeyListener) listeners[i]).nativeKeyTyped(e);
				break;

			case NativeKeyEvent.NATIVE_KEY_RELEASED:
				((NativeKeyListener) listeners[i]).nativeKeyReleased(e);
				break;
		}
	}
}
 
開發者ID:Hual,項目名稱:UploadR,代碼行數:30,代碼來源:GlobalScreen.java

示例5: processKeyEvent

import org.jnativehook.keyboard.NativeKeyEvent; //導入方法依賴的package包/類
/**
 * Processes native key events by dispatching them to all registered
 * <code>NativeKeyListener</code> objects.
 *
 * @param e the <code>NativeKeyEvent</code> to dispatch.
 * @see NativeKeyEvent
 * @see NativeKeyListener
 * @see #addNativeKeyListener(NativeKeyListener)
 */
private void processKeyEvent(NativeKeyEvent e) {
	NativeKeyListener[] listeners = eventListeners.getListeners(NativeKeyListener.class);

	for (int i = 0; i < listeners.length; i++) {
		switch (e.getID()) {
			case NativeKeyEvent.NATIVE_KEY_PRESSED:
				listeners[i].nativeKeyPressed(e);
				break;

			case NativeKeyEvent.NATIVE_KEY_TYPED:
				listeners[i].nativeKeyTyped(e);
				break;

			case NativeKeyEvent.NATIVE_KEY_RELEASED:
				listeners[i].nativeKeyReleased(e);
				break;
		}
	}
}
 
開發者ID:kwhat,項目名稱:jnativehook,代碼行數:29,代碼來源:GlobalScreen.java


注:本文中的org.jnativehook.keyboard.NativeKeyEvent.getID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。