• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying ArrayList data in a GUI's Text Fields - Part II

 
Dan D'Apice
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
OK, this is a continuation from my previous post. What I am trying to do is get the data (Item Name, Item Number, etc.) to display in my GUI's appropriate text fields (Item Number, Item Name, etc.). What I have for code so far is:




What I get in the output is:
Exception in thread "main" java.lang.NullPointerException
at inventory.InventoryGUI.<init>(InventoryGUI.java:17)
at inventory.InventoryGUI.main(Inventory.java: 18)

I assume that the jCombobox1 is not getting the data from the inventory array list I created. Or, I am completely wrong again. Sorry if I missed a couple of lines that needed "shortening". I tried a couple of suggestions from the original post, but every one generates errors. Any help is much appreciated.
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your inventory list in InventoryGUI is not initialized, you just declared it. So basically, it's a null, and hence the exception.
 
Dan D'Apice
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Kemal,
LOL, that was an OOPS on my part. Now that that's fixed, I just got smacked with a mega-error! I realize it's based off of me trying to incorporate a 3 item jComboBox into the mix, but this is what I got in the output....


I realize I missed quite a bit (as the error list shows), but if there is a quick explanation to this, it would help me filter out what I missed or did wrong...
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Besides this

I can't really tell what might be wrong (if the code you posted is the one that actually produced the exception). If you changed your code in the meantime, please post new version.

I realize it's based off of me trying to incorporate a 3 item jComboBox into the mix, but this is what I got in the output....

I must say that I don't really understand this part.
 
Dan D'Apice
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kemal,
Thanks for dealing with me all this time. Your input has been invaluable, however, I am furious right now and am throwing in the towel. I only have this week and one more week left to my Java class. I just can't get my head wrapped around this language. If anybody is thinking about going to University of Phoenix to learn Java, DON'T....they're terrible!! Good luck to everyone here, I'm done....thanks to everyone for the help....
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Really no need to give up. Giving up is not going to make a software developer from you.

The exception you are getting is saying that somewhere in your code you are trying to cast String to Book, and the trace also says that it happens in jComboBox1ActionPerformed method. I'm gonna have to ask you to post the entire code of your GUI class, because I can't really see what could go wrong in the code you posted. You're also gonna just have to edit a code a little when posting it, since the one generated by NetBeans is too wide for the code tags.

I also must notice that you didn't really follow the guidelines given by other Ranchers (including me) in one of your previous posts, before you even started implementing GUI (there were some notes on data types you used, wrong implementation of setters, perhaps some class design issues, etc.).

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic