本文整理匯總了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();
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
}
}
示例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;
}
}
}