File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Displaying ArrayList data in a GUI's Text Fields - Part II Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Displaying ArrayList data in a GUI Watch "Displaying ArrayList data in a GUI New topic
Author

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

Dan D'Apice
Greenhorn

Joined: Sep 26, 2012
Posts: 24
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

Joined: Jun 19, 2010
Posts: 825
    
    5

Your inventory list in InventoryGUI is not initialized, you just declared it. So basically, it's a null, and hence the exception.


The quieter you are, the more you are able to hear.
Dan D'Apice
Greenhorn

Joined: Sep 26, 2012
Posts: 24
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

Joined: Jun 19, 2010
Posts: 825
    
    5

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

Joined: Sep 26, 2012
Posts: 24
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

Joined: Jun 19, 2010
Posts: 825
    
    5

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.).

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying ArrayList data in a GUI's Text Fields - Part II
 
Similar Threads
Super class and Sub class inheritance not working
Making a GUI run and displaying data from a program that is already created.
New and desperately seeking help.
Unable to display data from an ArrayList