This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Image Loading, NullPointerException? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Image Loading, NullPointerException?" Watch "Image Loading, NullPointerException?" New topic

Image Loading, NullPointerException?

Nate West

Joined: Sep 14, 2012
Posts: 3
Hello, everyone. So, here is the basic layout of my project in Eclipse:

TestResources (This is a source folder):
Resources (Also a source folder):

So, with the following line of code from inside the BoxButton class (BoxButton extends javax.swing.JPanel), I'm getting a NullPointerException. What's wrong?

"gleam" is already declared as a java.awt.Image.

What am I doing wrong?
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11168

I am not a big fan of method chaining, for this reason - you can't tell which one is throwing the NPE.

Can you break it out into multiple calls and save each returned object? At least then you could figure out where the NPE is.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
It is sorta covered in the JavaRanch Style Guide.
subject: Image Loading, NullPointerException?
Similar Threads
Error launching JUnit
Eclipse:java files and source/build path question
How to have package names that don't begin with "src."?
Help with WSAD 4 and clearcase
Beginning locales ...