Click here to Skip to main content
15,888,018 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good friends and fellow developers, I am making an application in which components with certain characteristics must be created, which allows me to collect certain information to then process it, all this at runtime, in short, that part I am already working on the following shape:


Java
JpnlPunto jpnlComp = new JpnlPunto(index);//new instance to component
JpnlContPuntos.add(jpnlComp);//is added to jpanel
JpnlContPuntos.validate();
JpnlContPuntos.updateUI();
jpnlComp.setLocation(0, jlblBlock.getY()-45);//component position is established
JpnlContPuntos.repaint();
ubiComp.put(String.valueOf(jlblBlock.getY()-45), String.valueOf(i));//the positions of the components created on a map are saved
componentes.put(""+index, jpnlComp);//the created component is saved on a map
index++;
i++;


The components are created perfectly, NOW, my question is how to make these components remain once created, that is, once the application is closed and reopened they are visible where you create them!


Regards, I hope you can help me!


(sorry for my english, use google translator)


What I have tried:

I was investigating, and I found that by applying the serialization of the components these could be maintained but if someone could explain to me how to do it I would be grateful!
Posted
Updated 25-Jul-19 4:19am

Yes, serialization is the answer. You would need to save all details of each object in some permanent storage. When your application starts it should check fo the existence of the objects and deserialize them to their original form. See serialization java - Google Search[^].
 
Share this answer
 
Quote:
The components are created perfectly, NOW, my question is how to make these components remain once created, that is, once the application is closed and reopened they are visible where you create them!

Nothing done in the app can change the app itself.
Only 1 solution, use a configuration file to save a description of what you have done.
open app
read config file
restore custom settings
...
Change settings
save new config
...
close app
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900