• Post Reply Bookmark Topic Watch Topic
  • New Topic

Remembering frames position after quit/restart

 
Jean-Yves Tinevez
Greenhorn
Posts: 22
Eclipse IDE Mac Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!

I have a nice GUI made of JInternalFrames into a JDesktopPane.
I set the position and the size of each frame in the code, but i wonder if there was a way to save these positions and sizes when the user quits the GUI, and to restore them when the GUI is restarted.

Could someone orient me?
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about save it into a text file? When your application starts, read them back and set the position.

But, I want to know why you need to do this?
 
Jean-Yves Tinevez
Greenhorn
Posts: 22
Eclipse IDE Mac Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, I want to do that out of user-firendlyness. When the user opens the application, it is always nice to find it in the shape and organization it had when he left.

I have found this which might be of use:
http://java.sun.com/j2se/1.5.0/docs/guide/preferences/index.html
 
Gael Robin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the preferences API (the parameters are stored using the default OS service, windows registry for instance) see example for storing GUI settings

You could also use Resourcebundle (java.util.ResourceBundle) to store information in a file with .properties extension. This is a text file with string keys and values. It is generally used to localize application.

As an alternative you could create a class to store the parameters you want to save and write it to a file using serialization.

Hope this helps
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!