KeyListener vs. Runnable ???

Discussion in 'Java' started by JariTapio, Mar 25, 2005.

  1. JariTapio

    JariTapio Guest

    -!Hei!-

    Im makin a hot INVADERS game with Java
    but im a newbie with language, so , question is
    how do i use KeyPressed () function...

    I hav Applet Runnable and I dont know how to
    use keylistener when you use Applet Runnable...

    Thank you a lot for your help...
     
    JariTapio, Mar 25, 2005
    #1
    1. Advertising

  2. JariTapio

    JariTapio Guest

    -!Hei!-

    Here is my problem...

    public class TestinKeys extends Applet implements Runnable
    ....
    ....
    public void run ()
    {
    while ( true )
    {
    KeyEvent ke;
    if ( ke.getKeyChar() == 'a' ) g_TykkiX ++;
    ....
    ....

    What is Wrong, im tryin to make that Invaders game but i dont know
    how to read keyboard with Runnable Java code...
     
    JariTapio, Mar 25, 2005
    #2
    1. Advertising

  3. JariTapio

    Guest

    You need to implement KeyListener
     
    , Mar 25, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. apchar
    Replies:
    3
    Views:
    1,850
    Andrew Hobbs
    Feb 3, 2004
  2. Max

    JWindow KeyListener

    Max, Oct 29, 2005, in forum: Java
    Replies:
    4
    Views:
    3,782
  3. Luc The Perverse

    KeyListener

    Luc The Perverse, Nov 12, 2005, in forum: Java
    Replies:
    2
    Views:
    803
    Luc The Perverse
    Nov 12, 2005
  4. JavaEnquirer

    KeyListener losing its way

    JavaEnquirer, Dec 20, 2005, in forum: Java
    Replies:
    0
    Views:
    415
    JavaEnquirer
    Dec 20, 2005
  5. Replies:
    0
    Views:
    2,353
Loading...

Share This Page