devxlogo

Saving Panels with TextField?

Saving Panels with TextField?

Question:
I am writing a presentation application and want to take a Panel and add TextFields and maybe Images to it. Is it possible to save this Panel with TextFields on it to disk and reload it later without losing the size and the text of the TextFields?

Answer:
As long as all the components you add implement the Serializable interface and save their complete state, you should be able to save and restore your panel without losing its dimensions or contents. All of the basic components provided in the java.awt package as well as the com.sun.java.swing package are serializable. You just have to make sure that any new components you create are also serializable.

devx-admin

Share the Post: