java jnative new 错_Java-为什么会出现这些错误?

代码:

package keylogger;

import org.jnativehook.GlobalScreen;

import org.jnativehook.NativeHookException;

import org.jnativehook.keyboard.NativeKeyEvent;

import org.jnativehook.keyboard.NativeKeyListener;

public class GlobalKeyListenerExample implements NativeKeyListener {

public void nativeKeyPressed(NativeKeyEvent e) {

System.out.println("Key Pressed: " + NativeKeyEvent.getKeyText(e.getKeyCode()));

if (e.getKeyCode() == NativeKeyEvent.VK_ESCAPE) {

try {

GlobalScreen.unregisterNativeHook(); // LINE 18

}

catch (NativeHookException ex) {

System.err.println("You cannot call unregisterNativeHook() from the native dispatch thread.");

}

}

}

public void nativeKeyReleased(NativeKeyEvent e) {

System.out.println("Key Released: " + NativeKeyEvent.getKeyText(e.getKeyCode()));

}

public void nativeKeyTyped(NativeKeyEvent e) {

System.out.println("Key Typed: " + NativeKeyEvent.getKeyText(e.getKeyCode()));

}

public static void main(String[] args) {

try {

GlobalScreen.registerNativeHook(); // LINE 38

}

catch (NativeHookException ex) {

System.err.println("There was a problem registering the native hook.");

System.err.println(ex.getMessage());

ex.printStackTrace();

}

//Construct the example object and initialze native hook.

GlobalScreen.getInstance().addNativeKeyListener(new GlobalKeyListenerExample());

}

}

Cannot find unregisterNativeHook,registerNativeHook. //(line 18,38)

The IDE also says GlobalKeyListenerExample is not abstract and doesn't override abstract method keyReleased.

为什么我已经覆盖了第二个错误却又得到第二个错误?但是,当我在该方法之前添加@Override注释时,IDE会显示错误消息,指出该方法未覆盖或未从超类型实现.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值