I've been studying the book Heard First Java. This book has a code of "BeatBox" that demonstrates how to use the serialization / deserialization to save / restore standards of "hits".
Here's the part that I'm in doubt:
Creating SerializeIt button:
Inner class "listener" of SerializeIt:
Creating the Open File button:
Inner class "listener" Open the File:
The way my code is done I can save files, beat patterns. But when I try to restore a pattern, I can't. It does not restore the BeatBox.
I hope I was clear in explaining the problem. It is the first post that I create and my English is limited. If you want any further information, communicate with me.
Thanks for listening!
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." (Fowler)
In your loadFile and saveFile methods you do not modify any GUI elements. You do not even read / write the file contents. All I can see is the instantiation of the BufferedReader / BufferedWriter and the close call. I think you might need to actually read / write something.
Me don't see no seralitation in provided code ; -
OK, so you serialize to a fixed filename (not in saveFile method though), but you don't ever read data.
Censorship is the younger of two shameful sisters, the older one bears the name inquisition. -- Johann Nepomuk Nestroy
Joined: Jun 14, 2010
I think it's best to put the complete code:
Here it is!
I think I actually read in a file and record the sequences of each JCheckBox(method loadFile() and saveFile()). But in the moment to restore the GUI for the file, it does not happends. I think I need to do one more thing in the method loadFile (), I just don't know what it is.