• Post Reply Bookmark Topic Watch Topic
  • New Topic

JFilechooser save using the object serialization  RSS feed

 
Mohamad Samy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have the following code (it might be silly). the save button should open the jfile chooser and if approved save the panel containing the components and the load button retrieve the panel again to be added to the program.
but i can't do this.

 
Sam Gooding
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to look at this earlier question:

http://www.coderanch.com/t/562824/GUI/java/Serialize-GUI-Swing

 
Mohamad Samy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it doesn't answer my question.
 
Sam Gooding
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohamad Samy wrote:it doesn't answer my question.


Are you getting an error? Can you post it?

When I have something huge and I don't know what part of it is causing trouble, I remove almost everything until I have something so stupid simple, it just has to work (or not!!) . Then I incrementally add lines to it, as semantics permit, until it breaks again. When it breaks , I know I have found probably the first of my problem(s).
 
Andrea Binello
Ranch Hand
Posts: 47
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohamad Samy wrote:i have the following code (it might be silly). the save button should open the jfile chooser and if approved save the panel containing the components and the load button retrieve the panel again to be added to the program.
but i can't do this.

Please, note one thing: in the save action you get and save the content pane. Ok. But in the load action you load and add to the content pane.

Since the content pane has a GroupLayout, and for the addition you didn't specify any constraints, GroupLayout is unable to arrange that new component. At least you should replace the content pane, that has more sense.

And finally another (personal) impression: you are developing a temperature converter. I suspect that the save/load of an entire component graph is not really the best and valid solution.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!