Error getInstance

4 respostas
java
M

Boa noite estou criando um projeto mais esta dando erro.

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package olehelp;
import java.util.logging.Level;

import java.util.logging.Logger;

import jdk.nashorn.internal.objects.Global;

import org.jnativehook.GlobalScreen;

import org.jnativehook.NativeHookException;

import org.jnativehook.keyboard.NativeKeyEvent;

import org.jnativehook.keyboard.NativeKeyListener;

/**

*

*

*/

public class Olehelp implements NativeKeyListener {
/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    
    try {
        GlobalScreen.registerNativeHook();
    } catch (NativeHookException ex) {
        
    }
    
    GlobalScreen.getInstance().addNativeKeyListener(new olehelp());

//nessa linha dando erro, sinal de exclamação
}

@Override
public void nativeKeyPressed(NativeKeyEvent nke) {
    
    System.out.print(NativeKeyEvent.getKeyText(nke.getKeyCode()));
}


@Override
public void nativeKeyReleased(NativeKeyEvent nke) {
}

@Override
public void nativeKeyTyped(NativeKeyEvent nke) {
}

}

4 Respostas

S

Tem certeza que esse é o construtor da classe?

M

Sim…

M

sim

S

Estranho, pois sua classe se chama Olehelp e você está fazendo um new olehelp.
Dá uma olhada, pois Olehelp é diferente de olehelp.

Criado 27 de março de 2018
Ultima resposta 5 de abr. de 2018
Respostas 4
Participantes 2