File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JButton not displaying, throwing NullPointerException

 
Justin Dutch
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trying to display buttons through a method. Keep getting NullPointerException at line 41. What am I doing wrong?

 
K. Tsang
Bartender
Pie
Posts: 3225
12
Android Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you determine which of those 4 variables is/are null? Once you do you can solve your own problem.

And welcome to the Ranch.
 
Rob Camick
Ranch Hand
Posts: 2475
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your addOpButton() method doesn't do what you expect it to do. Java uses "pass by value" so only a copy of the button reference is passed to the method. So your variable still remains null. You need to change your code to something like:

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic