Losing Focus?

So I'm messing around with a program that takes in keyboard input, (the arrow keys in my case) then moves a square around. It worked perfectly until I added a new Panel that contained some simple menu buttons, one of which starts my animation timer.

Basically, I have Timer - animation - which has the actionEvent which controls the square depending on whether booleans (right, left, up, down) are true or false. The keyPressed/keyReleased events will toggle the booleans. I then wanted a button that started the animation timer as opposed to it just starting right when the window pops up. I added the button, but then when I press it, The game panel (with the square in it) seems to loose focus of what the keyboard is doing and can't read my input. I'm super confused, becuase I Printed out whether the Panel had focus or not, and it returns true. I've also set the panel focusable(true) a second time when the button is pressed.

Any ideas?

I'll clarify anything up if need-be, I tried keeping it short and probably skipped over a bunch of stuff.

Thanks,

Phil

[1104 byte] By [olsonpma] at [2007-11-27 4:55:46]
# 1
Call requestFocusInWindow() method.
hiwaa at 2007-7-12 10:10:47 > top of Java-index,Java Essentials,Java Programming...
# 2
Thanks, I thought I tried that but I guess not. I'll read up on why the hell (component).isFocusable(true) is different from (component).requestFocusInWindow()Message was edited by: olsonpm
olsonpma at 2007-7-12 10:10:47 > top of Java-index,Java Essentials,Java Programming...
# 3

> Thanks, I thought I tried that but I guess not. I'll

> read up on why the hell (component).isFocusable(true)

> is different from (component).requestFocusInWindow()

>

> Message was edited by:

> olsonpm

I'm guessing you mean "setFocusable(true)" :-)

The difference between the two methods you mentioned? Consider the following sentences

1) Here is a potato peeler

2) Please peel some potatoes for me

georgemca at 2007-7-12 10:10:47 > top of Java-index,Java Essentials,Java Programming...