Computer Science Canada Arrow Keys |
Author: | eclipto [ Fri Nov 24, 2006 6:15 pm ] |
Post subject: | Arrow Keys |
Does anyone know how to move objects drawn in a paint method with the arrow keys ![]() |
Author: | wtd [ Fri Nov 24, 2006 6:44 pm ] |
Post subject: | |
Well, your class has the positions of the objects as instance variables. Your paint method uses this information to paint them on the canvas. So your real question is how you change that information in response to a keypress. ![]() The solution lies in understanding KeyListeners. |
Author: | eclipto [ Fri Nov 24, 2006 6:48 pm ] |
Post subject: | |
Would it be possible for you to explain keyListener to me? i havent been taught this area yet |
Author: | wtd [ Fri Nov 24, 2006 6:51 pm ] |
Post subject: | |
I would, but there are already many many explanations readily available, and just a Google search away. Also, understanding interfaces and anonymous inner classes will help tremendously. You can find explanations of these concepts in my Intoduction to Java in the [Java Tutorials] forum. |