Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to save properly?

 
Avin Sinanan
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I created some code to add draggable buttons to a JPanel.
Every added button can be moved around once added to the JPanel. That is, when every you add a button you can now move it around. It saves and everything. However when you opened back a saved file the buttons cannot be moved. When the saved button appears back on the screen you cannot drag the buttons around again.. Can you help me please. Am really inexperinced in saving and opeing stuff. I tried reading tutorials on the net but its not a big help. Sorry for being a pest. Anyway here is the code.. and thanks for even looking at it...
Yours respectfully Avin Sinanan.. here is the code..



thanks
[ March 02, 2002: Message edited by: Avin Sinanan ]
[ March 02, 2002: Message edited by: Avin Sinanan ]
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Avin,
Last time I seen this code you had a MoveableButton class and that was what you serialized.
Serialization only saves an objects' state. What does that mean? It means that only class variables are saved. For AWT or Swing components that means that only things that can be set or get are serialized. Things that are added are not saved.
Your problem is that you are thinking that the mouselistener that was added will be saved and brought back. That is not the case as you have probably observed. You will need to add the mouse listener once again to the buttons once you read them in and then it will work as you expect.
Regards,
Manfred.
 
Those are the largest trousers in the world! Especially when next to this ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!