KeyListener

Discussion in 'Java' started by Luc The Perverse, Nov 12, 2005.

  1. In an attempt to familiarize myself with Sprite animation I have made an
    exceptionally simple example.

    I have a class called AnimationFrame (class AnimationFrame extends
    javax.swing.JPanel implements Runnable, KeyListener) but I can't seem to get
    it to keylistener events unless I drop an object in there and give it focus.

    Any way I can avoid this? I don't want to have to have a fake control on
    the front of my game.

    --
    LTP

    :)
     
    Luc The Perverse, Nov 12, 2005
    #1
    1. Advertising

  2. Luc The Perverse

    Michael Dunn Guest

    "Luc The Perverse" <> wrote in message
    news:43758449$0$8288$...
    > In an attempt to familiarize myself with Sprite animation I have made an
    > exceptionally simple example.
    >
    > I have a class called AnimationFrame (class AnimationFrame extends
    > javax.swing.JPanel implements Runnable, KeyListener) but I can't seem to
    > get it to keylistener events unless I drop an object in there and give it
    > focus.
    >
    > Any way I can avoid this? I don't want to have to have a fake control on
    > the front of my game.



    do you have in the AnimationFrame constructor

    setFocusable(true);
     
    Michael Dunn, Nov 12, 2005
    #2
    1. Advertising

  3. "Michael Dunn" <> wrote in message
    news:43758e7a$...
    >
    > "Luc The Perverse" <> wrote in message
    > news:43758449$0$8288$...
    >> In an attempt to familiarize myself with Sprite animation I have made an
    >> exceptionally simple example.
    >>
    >> I have a class called AnimationFrame (class AnimationFrame extends
    >> javax.swing.JPanel implements Runnable, KeyListener) but I can't seem to
    >> get it to keylistener events unless I drop an object in there and give it
    >> focus.
    >>
    >> Any way I can avoid this? I don't want to have to have a fake control on
    >> the front of my game.

    >
    >
    > do you have in the AnimationFrame constructor
    >
    > setFocusable(true);


    SWEET!

    I had no idea it would be that simple. Thank you!

    --
    LTP

    :)
     
    Luc The Perverse, Nov 12, 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,851
    Andrew Hobbs
    Feb 3, 2004
  2. JariTapio

    KeyListener vs. Runnable ???

    JariTapio, Mar 25, 2005, in forum: Java
    Replies:
    2
    Views:
    749
  3. Max

    JWindow KeyListener

    Max, Oct 29, 2005, in forum: Java
    Replies:
    4
    Views:
    3,782
  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