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

+2


source to share


4 answers


Are you sure you want to save the view and not the model? Another method besides Preferences is to use XMLEncoder



+2


source


I don't know about sqlite but Preferences

is a good way to store information about your JFrame

.



+1


source


As far as I know, it is actually not possible to store the JFrame in the database. Whether you do it yourself or with some kind of library, how it works, you store in the db all the information you need to recreate your JFrame.

0


source


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

0


source







All Articles