Re: Saving/Restoring state
- From: tar@xxxxxxxxxxxxx (Thomas A. Russ)
- Date: 07 Mar 2007 11:50:26 -0800
"dunerunner" <tpdietz@xxxxxxxxx> writes:
I'm curious. I am in need of a dialog with which the user can restore
the original state of the components. For example, say I have a
jcheckbox, a jcombobox and a jlist that are in a certain state upon
creation of the dialog. I want to save their state upon creation.
The user can click away and change the component states, but when they
click the Restore Defaults button, I want to restore the state of
those components to when the dialog was first created.
I know I can do it in a brute-force way but, I'm wondering if there
are any ideas out there to handle this generically (maybe using
reflection) where the method can apply to any number of components in
any dialog.
Ideas?
I think you need to approach this from the opposite direction.
Instead of thinking of the dialog as being the central item and figuring
out how to generate the state information automatically from the dialog,
go the other way.
Define a representation of the state that you are trying to set. This
will provide an object that represents the state. This state object is
what is queried by the application whenever it needs to get state
information.
When you need user input, either use reflection to examine the state
object, or augment the state object itself with additional methods and
generate the dialog components. You can base the components on the type
of the individual fields of the state.
--
Thomas A. Russ, USC/Information Sciences Institute
.
- Follow-Ups:
- Re: Saving/Restoring state
- From: dunerunner
- Re: Saving/Restoring state
- References:
- Saving/Restoring state
- From: dunerunner
- Saving/Restoring state
- Prev by Date: Re: A JLabel's Size
- Next by Date: Re: A JLabel's Size
- Previous by thread: Saving/Restoring state
- Next by thread: Re: Saving/Restoring state
- Index(es):