I would like to learn how to save a JInternalFrame.
Currently reading through Serialize info.
I have never ran the app outside of Netbeans. I have had no success with creating
the jar for the app (JDesktopPane). Now Serialization is adding to the confusion.

Do I have to have the JMenuItem on the JInternalFrame to open a JFileChooser to save the
file in a Location and call a method or class to use the Streams to put it there?
Thanks

In a word - yes.
You need to call JFileChoser in response to some kind of user interaction - eg clicking a menu item.
The JFileChooser returns you a File object, so you then open some kind of output Stream (eg new ObjectOutputStream) to that File, and write your data to the Stream

In a word - yes.
You need to call JFileChoser in response to some kind of user interaction - eg clicking a menu item.
The JFileChooser returns you a File object, so you then open some kind of output Stream (eg new ObjectOutputStream) to that File, and write your data to the Stream

Thanks. I am on the right trail then. However,I have been able to collect info on
JFileChooser and Serializable but not a single example that shows them working together.
They both seem like vital operations. I wonder why there is a void in code examples.

JFileChooser gives you a file.
Serialization writes to a file.
You really don't need anything else. Just start with the file chooser and use its file in the serialization. One just goes right after the other. Try it.

Here, stripped of all the error handling etc, is the essential sequence of steps:

JFileChoser jfc = new JFileChoser(...
jfc.showSaveDialog(...
File f = jfc.getSelectedFile();
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f));
oos.writeObject(myObject);
oos.close();

You can get all the error and exception handling from the examples you have already found.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.