Results 1 to 16 of 16
  1. #1
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default KeyListener doesnt work some times.

    Hello
    Because people did not realise that I NEED to learn to hack
    (to prevent slaughter of christians in a couple of years)
    and instread decided to becoming jerks,I decided
    to do something else. A 2d simple game.

    now, for no reason what so ever!
    The key listener stops working! :(
    I added it to the JFrame AND to the JPanel contaning my
    drawings of sqares but now it stopped working AGAIN!!


    First it works. you can drive you lil helicopter, but then suddenly during
    one my my debugs, it stops working.
    No input is gatherd whatso ever!
    Why?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default

    Hard to tell without more info about the code and the OS it is running on.
    Does the component with the listener have the focus?

  3. #3
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Quote Originally Posted by Addez View Post
    Hello
    Because people did not realise that I NEED to learn to hack
    (to prevent slaughter of christians in a couple of years)
    and instread decided to becoming jerks,I decided
    to do something else. A 2d simple game.

    now, for no reason what so ever!
    The key listener stops working! :(
    I added it to the JFrame AND to the JPanel contaning my
    drawings of sqares but now it stopped working AGAIN!!


    First it works. you can drive you lil helicopter, but then suddenly during
    one my my debugs, it stops working.
    No input is gatherd whatso ever!
    Why?
    first of all what has religion got to do with code. second of all where is your example code, third of all what?

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,447
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Addez View Post
    Because people did not realise that I NEED to learn to hack
    (to prevent slaughter of christians in a couple of years)
    That is a preposterous argument; if it weren't so ludicrous I'd report your topic.

    Jos

  5. #5
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default

    Yes I think so.
    I got a JLabel inside a JFrame and thats all.
    When I click it, one of them should get the focus right?

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,447
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Addez View Post
    Yes I think so.
    I got a JLabel inside a JFrame and thats all.
    When I click it, one of them should get the focus right?
    From the API documentation of the JLabel class:

    Quote Originally Posted by API
    A display area for a short text string or an image, or both. A label does not react to input events. As a result, it cannot get the keyboard focus. A label can, however, display a keyboard alternative as a convenience for a nearby component that has a keyboard alternative but can't display it.
    kind regards,

    Jos

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by JosAH View Post
    That is a preposterous argument; if it weren't so ludicrous I'd report your topic.Jos
    The posts above certainly suggests that we be observant.

  8. #8
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default

    Dear Josh,
    I realize that you are talking with eloquence in order to attain credibility
    that you are of superior kind when arguing over these mathers.
    I will therefore reply in the same elocutio.

    Allow me to inform sir that I have not failed to furfilled every rules
    applied to this specific page. Rather I came with a non-debateable
    statement that the end of time is certainly approaching.


    As for my real question:
    Soo..
    I got a JFrame, yet the keylistener stops working at random points
    when I debug..
    Hum.. Should I use something else instead of keylistener?

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default

    Could you post a small program that compiles and executes and demonstrates your problem?

  10. #10
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default

    Found out what it was.
    I forgot to add:
    @Override
    thingy over my methods.. -.-

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    Sometimes this place really throws up some surprises...:)

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default

    But that doesn't explain the "sometimes" aspect of the problem. Either the method was an override or it wasn't

  13. #13
    Addez is offline Senior Member
    Join Date
    Aug 2009
    Posts
    294
    Rep Power
    0

    Default

    Idk why, but it stopped it.
    It works always now, as before only worked 50% of the time.

  14. #14
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  15. #15
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,318
    Rep Power
    25

    Default

    AFAIK Computers are very consistent. There has to be something else about your code that allowed the "sometimes" aspect of the problem.

  16. #16
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    Quote Originally Posted by Fubarable View Post
    As far as I know, @Override will only effect the compilability of the code, not the behavior of the code.
    @Override doesn't stop it from compiling unless it is applied to a method that doesn't exist in a superclass.

Similar Threads

  1. PrintWriter doesnt work :(
    By Addez in forum New To Java
    Replies: 11
    Last Post: 01-17-2010, 05:59 PM
  2. mysql connect button doesnt work quite right
    By 711groove in forum New To Java
    Replies: 0
    Last Post: 12-13-2009, 07:01 AM
  3. why doesnt my insertion sort method not work?
    By Jeremy8 in forum New To Java
    Replies: 7
    Last Post: 11-15-2009, 02:56 AM
  4. Dll Call doesnt work
    By INFACT in forum New To Java
    Replies: 1
    Last Post: 10-04-2009, 09:31 PM
  5. java doesnt allow vista to work
    By 10rosas in forum New To Java
    Replies: 5
    Last Post: 12-22-2008, 04:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •