File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes How to save configuration for my application?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to save configuration for my application??" Watch "How to save configuration for my application??" New topic

How to save configuration for my application??

Michelle Wang
Ranch Hand

Joined: Apr 17, 2007
Posts: 87
I have a GUI application, see code below, after I run it, I re-organize the positions for all labels, eg. I put them into different poistions, or put then into center of JPanel. then I quit my application,
nect time, when I re-run this program, I hope to see this last layout that I quit before: all labels are in center of JPanel,
I google a while, no good results.
Please advice how to do it and where to get goo example??

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10825

I had once worked on a similar requirement, where the user could select which columns in a table to display, their order, their preferred widths etc. We had come up with a preference framework which helped us do it.

In your case, you can try a similar approach. Essentially you will need to persist the information regarding the labels in some form while quitting the application. The next time you launch the application, you can retrieve this information and use it while laying out the components.

Persisting Preference Objects or using a properties file or some DB are likely solutions. The choice depends on what kind of framework you are using.

A google on "java preference framework" will give you good results.
Best of luck.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
I agree. Here's the link:
subject: How to save configuration for my application??
It's not a secret anymore!