Skip to content
Advertisement

Array de-serialization in a Java GUI problems

now I need some help with Serializing my arraylist. Now I have managed to get the serializing aspect working (I think at least), now my problem lays with de-serializing the object. I am making a small address book program. I have a comboBox that stores the addresses with three textboxes above where the user enters: name, address, and phone number. For testing purposes I then have a save and load button. The save button saves the contacts, and the load button loads the previous sessions contacts. Now everything but the de-serializing works and I would like to know how to proceed with it.

My code is bellow:

JavaScript

Here is my object:

JavaScript

This next splotch of code is in my Address_Book class, the first code I gave you, this is just to make it easier to find where I am loading it from.

JavaScript

Thank you for your time, if you have any questions don’t hesitate to ask. 🙂

Advertisement

Answer

  • Your Book class doesn’t implement Serializable. Fix this as this is the cause for your exception and is thus the primary reason your current attempt to serialize the ArrayList<Book> is failing.
  • Google for and read a serialization tutorial.
  • Again, don’t use MouseListeners on JButtons when you should be using an ActionListener. This isn’t causing your problem but will cause future problems if not fixed. Please read the Java tutorials on how to use JButtons as it’s all very explained there.
  • Again, when you try to implement a new complex functionality to an already complex program, do it in isolation of the complex program first so as to isolate and fix any problems before adding it to the greater program. This is doubly true if your new code causes an error.
Advertisement