How to store and get a swing component object in a database, java
Hi I have written a small java program based on swing application. Now I want to store my swing application object (jframe) in the database and I want to get it from the database when needed. during fetching I want to get the same object. I am using sqlite as a database
How to achieve this functionality
Thanks Sunil Kumar Sahoo
source to share
Are you sure you want to save the view and not the model? Another method besides Preferences is to use XMLEncoder
source to share
JFrame implements Serializable, so in theory it serializes as ObjectStream, which you can use ObjectInputStream and ObjectOutputStream and write the stream to the database.
All components in the JFrame must also be serializable. However, this is not really recommended as the api says "Serialized objects of this class will not be compatible with future versions of Swing."
source to share