• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Image Loading, NullPointerException?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, everyone. So, here is the basic layout of my project in Eclipse:

Project:
Src:
package1:
BoxButton.java
package2:
Test.java
TestResources (This is a source folder):
resourcesfortest.images:
t.png
Resources (Also a source folder):
res.images:
gleam.png


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?
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic