Page 2 of 2 FirstFirst 12
Results 21 to 30 of 30
Like Tree2Likes

Thread: Using KeyListener - get a gazillion errors

  1. #21
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default Re: Using KeyListener - get a gazillion errors

    Quote Originally Posted by supremegrandruler View Post
    I'm using Eclipse for Android(
    The Android part is confusing me a little as you are writing a desktop (Swing) Java program.

    I assume this isn't an Android specific version of Eclipse.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  2. #22
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,773
    Rep Power
    25

    Default Re: Using KeyListener - get a gazillion errors

    I don't see anything that's null
    Try adding some println statements to show what variable has a null value.

    What software are you using to execute the java class? Not getting a standard stacktrace will make it a bit harder to debug the code.
    If you don't understand my response, don't ignore it, ask a question.

  3. #23
    Join Date
    Mar 2014
    Posts
    72
    Rep Power
    0

    Default Re: Using KeyListener - get a gazillion errors

    Quote Originally Posted by Tolls View Post
    The Android part is confusing me a little as you are writing a desktop (Swing) Java program.

    I assume this isn't an Android specific version of Eclipse.
    Yea you're right. It's just a version of Eclipse that you can code for Android on but you can also code desktop programs. I tried using the normal version downloaded from the Eclipse website and I still get the same errors anyway.

    @Norm, I'm using the normal Eclipse IDE to run the program. How can I use print msgs to show what variables are null?

    But you guys have tried it right? You don't get any "printed" errors but no keys are displayed to the console even though they should (that's an error of itself).

    Could you try coding a simple keylistener class that prints pressed keys to the console, see if it works, and send it to me so I can see on my end?

  4. #24
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,773
    Rep Power
    25

    Default Re: Using KeyListener - get a gazillion errors

    How can I use print msgs to show what variables are null?
    Without a stacktrace to point to a statement, it will be harder.
    Add lots of print statements. When then NPE happens it will be on a statement after the last println that printed and before the next println that did not print. Add more println statements between those two statements until you find what variable has the null value.
    If you don't understand my response, don't ignore it, ask a question.

  5. #25
    Join Date
    Mar 2014
    Posts
    72
    Rep Power
    0

    Default Re: Using KeyListener - get a gazillion errors

    Quote Originally Posted by Norm View Post
    Without a stacktrace to point to a statement, it will be harder.
    Add lots of print statements. When then NPE happens it will be on a statement after the last println that printed and before the next println that did not print. Add more println statements between those two statements until you find what variable has the null value.
    I added print msgs before and after every method. The error appears right before I push a key.

  6. #26
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,773
    Rep Power
    25

    Default Re: Using KeyListener - get a gazillion errors

    The error appears right before I push a key.
    You need to Add more println statements to get a message to print BEFORE the error happens.
    If there are no user inputs when the error happens, what event is causing the code with the error to execute?
    If you don't understand my response, don't ignore it, ask a question.

  7. #27
    Join Date
    Mar 2014
    Posts
    72
    Rep Power
    0

    Default Re: Using KeyListener - get a gazillion errors

    Quote Originally Posted by Norm View Post
    You need to Add more println statements to get a message to print BEFORE the error happens.
    If there are no user inputs when the error happens, what event is causing the code with the error to execute?
    How can I do that? The error appears when I push a key. If I don't do anything, no error. I don't know how I can put print statemtns to help me with this. :(

  8. #28
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,260
    Rep Power
    6

    Default Re: Using KeyListener - get a gazillion errors

    Sorry to say, that crash is something internal in the MacOS runtime / window manager code. Its nothing to do with your own code. If you want help with it, you'll have to find some corner on the internet where die hard Mac Java programmers hang out; then you'll have a chance of running into someone that has seen this before.

    The way I can say that with such certainty is because I've been dealing with wonky errors long enough to know to extract a piece of it and toss it into google. In this case I picked the part of the stacktrace that is just below the exception signalling entries:

    AppKit 0x00007fff95af275d -[NSTextInputContext handleTSMEvent:

    But I reason that hexadecimal number is specific to you, so I stripped it out. I googled this:

    AppKit -[NSTextInputContext handleTSMEvent

    You get plenty of results that way. I don't see much in the form of an answer, but you're not the first to run into this.
    jim829 and Norm like this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  9. #29
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,910
    Rep Power
    5

    Default Re: Using KeyListener - get a gazillion errors

    Nice bit of detective work!

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  10. #30
    Join Date
    Mar 2014
    Posts
    72
    Rep Power
    0

    Default Re: Using KeyListener - get a gazillion errors

    Thanks for the answer. It's funny but if I make an applet, I don't get the error. Anyway, thanks for the help everyone. :)

Page 2 of 2 FirstFirst 12

Similar Threads

  1. KeyListener?
    By MW130 in forum New To Java
    Replies: 22
    Last Post: 01-13-2014, 03:28 PM
  2. KeyListener
    By Nh bcu in forum New To Java
    Replies: 2
    Last Post: 10-15-2013, 11:07 AM
  3. Replies: 4
    Last Post: 01-04-2011, 01:36 AM
  4. Replies: 3
    Last Post: 03-08-2009, 02:51 AM
  5. KeyListener Example
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-11-2008, 05:46 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
  •