Results 1 to 4 of 4
  1. #1
    PFworth is offline Member
    Join Date
    Apr 2010
    Posts
    2
    Rep Power
    0

    Unhappy ERROR: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

    I've been making a NetBeans Java version of Blackjack, and yesterday I came upon an error that has left my program error-ing out as soon as it launches. I'm new to Java, but I am very experienced with VB. The error reads,

    run:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at javax.swing.ImageIcon.<init>(ImageIcon.java:167)
    at Main.initComponents(Main.java:118)
    at Main.<init>(Main.java:51)
    at Main$5.run(Main.java:661)
    at java.awt.event.InvocationEvent.dispatch(Invocation Event.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 597)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)
    BUILD SUCCESSFUL (total time: 2 seconds)


    I really have no clue where to begin in getting my program to run. I'd really like to keep my program, rather than write it all over again! :cursing:

    My screen is thrown off entirely as well, but that's less of a concern.

    Thank you in advance!

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,570
    Blog Entries
    7
    Rep Power
    21

    Default

    Read the stack trace:

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at javax.swing.ImageIcon.<init>(ImageIcon.java:167)
    at Main.initComponents(Main.java:118)
    In your initComponents( ... ) method at line 118 it tries to do something with an ImageIcon. That icon is probably null. Show us the relevant part of your source code (don't dump everything here) if you can't figure out what's happening. Tip: System.out.println( ... ) everything that might look suspicious to you.

    kind regards,

    Jos

  3. #3
    PFworth is offline Member
    Join Date
    Apr 2010
    Posts
    2
    Rep Power
    0

    Thumbs up

    JosAH, thank you so much! Somehow the source of my image was screwed up (it was pathing from the incorrect folder). The form is still messed up when it isn't run (in the creator), but when I run the program it is perfect.

    Thank you again!

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,570
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by PFworth View Post
    JosAH, thank you so much! Somehow the source of my image was screwed up (it was pathing from the incorrect folder). The form is still messed up when it isn't run (in the creator), but when I run the program it is perfect.

    Thank you again!
    You're welcome of course and b.t.w. you're welcome to this forum. Here's a tip: try to read what those stack traces have to say when the jvm spits them at you: they at least give you a clue of what had happened.

    kind regards,

    Jos

Similar Threads

  1. Replies: 4
    Last Post: 04-01-2010, 10:34 PM
  2. Replies: 5
    Last Post: 08-26-2009, 11:37 AM
  3. Replies: 6
    Last Post: 08-03-2009, 08:58 PM
  4. Replies: 12
    Last Post: 10-05-2008, 06:52 AM
  5. Replies: 3
    Last Post: 01-29-2008, 01:37 AM

Posting Permissions

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