I've got large Swing application with more than 50 views (forms, dialogs, menus, popups, etc..). What I need is some intelligent way of persisting view states and bringing them back to life. There are lots of tables, splitters, check boxes and other visual elements which users would want to have preserved. Of course I'd be able to do this manually.. but on such a scale it would be a monstrously tedious coding and bugs all around the place.
The question: Is there any framework, library or a product which does this without too much hassle? The problem sounds to be pretty common place, so I'd rather find something solid instead of re-inventing the wheel.
First, separate your data (model) from your Swing components (view)
Once you have a complete data model, you can use an XML generator / XML parser to save and restore your data model, respectively. You can use a relational database to save and restore your data model. Whatever makes the most sense for the amount of data in your model.
I have an example of a Java Swing model and a view in this answer.
Edited to add: One of Dima's assertions is Take for example a JTable with 20 columns 5 of which user made visible while hiding others and also making columns of a certain width.
Fine. The TableModel, column visibility booleans, and column width integers or doubles had better be somewhere in your model.
Follow the link to my other answer and see that my GUI state data is part of the model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With