KeyListener in JAVA

I will be setting up a program that uses keyListener. But for whatever reason it doesn’t perform. When I complie that i get one particular error:

PythagoreanTriple. coffee 123: 1 missing method body, as well as declare abstract
open public void keyReleased(KeyEvent e);

Code:
open public void keyPressed(KeyEvent e)

int keycode = age. getKeyCode();
if(keycode == KeyEvent. VK_TAB)

displayN. requestFocus();


open public void keyTyped(KeyEvent e)


open public void keyReleased(KeyEvent e);

displayN. requestFocus();

I don’t know why. Theoretically it should work.

Might anyone help me

Thanks!

The problem is that you then have a semicolon (; ) immediately following keyReleased method announcement. The compiler thinks you aren’t creating a body, and declaring method and not using a body, which is only allowed with abstract methods.

This is how your computer code should look:

Code:
open public void keyPressed(KeyEvent e)
int keycode = age. getKeyCode();
if(keycode == KeyEvent. VK_TAB)
displayN. requestFocus();


open public void keyTyped(KeyEvent e)

open public void keyReleased(KeyEvent e)
displayN. requestFocus();

Try it and determine if it works!

WHOA. I am now wondering how POST looked over which. It was at school, so I got probably only half paying attention, but two some people missed it far too.

Thanks!

This entry was posted in Web Design and tagged , , , , , , , , . Bookmark the permalink.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *