Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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

NPE when adding combobox selection to my jList

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79475
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you!

Im not sure what you mean ?

Can you please explain it for me?
 
Campbell Ritchie
Marshal
Posts: 79475
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79475
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which line does 19 refer to? Is it the same as 19 on the post?
 
Rancher
Posts: 3324
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Good heavens! What have you done! Here, try to fix it with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic