0

I have such a class KeyListener but when you want to compile a program in this class gives me an error:

Error: can not find symbol

class MyKeyListener implements KeyListener{

        Program applet;
        MyButton button;
        MyKeyListener(Program applet, MyButton button){
            this.applet = applet;
            this.button = button;
        }

        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == e.VK_0) {
                    button.doClick();
            }
        }
        public void keyReleased(KeyEvent e) {}
        public void keyTyped(KeyEvent e) {}
    }
Alexey Malev
  • 6,408
  • 4
  • 34
  • 52

1 Answers1

0

Most likely that error message means that IDE (or Java compiler) is unable to find one of your classes - KeyListener, Program, MyButton or KeyEvent. To fix that, you have to add all these classes (or its jar files) into the classpath.

See Javac vs Java within -classpath option

Community
  • 1
  • 1
Alexey Malev
  • 6,408
  • 4
  • 34
  • 52