Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NPE when adding combobox selection to my jList

 
Sean Gomes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys.

I got a problem with my java program, and im new to java.

I get an NPE and after severals hours yesterday I gave up.

I have now created a profile in here, so I hope somebody can help me

I want to make a combobox selection, and paste it to my jList, but even if I found many solutions on google yesterday I still get this NPE

NPE says that the problem is at line 19 in my ActionHandler class

My english is alittle rusty, so I hope you understand me.


My GUI Class


My ActionHandler for GUI


NPE
 
Campbell Ritchie
Sheriff
Pie
Posts: 48972
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please tell us which line number in your code corresponds to the line numbers in that stack trace.
 
Sean Gomes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you!

Im not sure what you mean ?

Can you please explain it for me?
 
Campbell Ritchie
Sheriff
Pie
Posts: 48972
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somewhere in the stack trace there will be a reference to a line you wrote. Which is the first line in the stack trace which you wrote? You can work it out from the numbers shown in the stack trace.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48972
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which line does 19 refer to? Is it the same as 19 on the post?
 
Rob Camick
Ranch Hand
Posts: 2584
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
18. public InvoiceApplication gui; // you define a variable with the value null here
19. ...
44.
45. public InvoiceApplication() {
46.
47. AcHandler actionH = new AcHandler(gui); // then you pass it to your handler and it is still null

There is no need to create an InvoiceApplicataion variable. If you want to refer to the current class you just use the java keyword "this". So your code should be:


 
Sean Gomes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much Rob its works now!

Thank to all of you I will close this thread.

Have a nice day

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic