Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Trouble using handleEvent

  Asked By: Rani    Date: Jan 27    Category: Java    Views: 590
  

I've got this problem with an applet.

I've always found the handleEvent method to work perfectly for me
before and I can't see what I'm doing differently.

I try the following code

public boolean handleEvent(Event e)
{
switch(e.id)
{
case Event.KEY_ACTION:
case Event.KEY_PRESS:
{
switch(e.key)
{
case Event.LEFT:
{
ball_x[0][0]-=100;
repaint();
break;
}
}
break;
}
}
return(false);
}

Debugging I find this works if I put the lines
"ball_x[0][0]-=100;repaint();" outside the switch statments, i.e. it
works for all mouse events like moving the mouse , but it doesn't
even work for any keys never mind pressing the left-arrow key.
It's probably a lot to ask, seen as I haven't given the whole
program, but does anybody know what could be wrong here?

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Trouble using handleEvent Or get search suggestion and latest updates.




Tagged: