Saving and loading Java Swing

I have a Java Swing application that contains a bunch of frames, which in turn basically contains tables showing large amounts of data. Since it is always difficult to start all windows and tables at startup, I would like to implement the โ€œworkspaceโ€ functionality so that the user can save the preference setting and at startup choose to automatically load the saved workspace into all windows and tables displayed as previously saved. In particular, the settings that I want to save in the workspace:

  • Active windows (JFrame) and their sizes and positions on the screen
  • Table settings, including selected columns, column order, column width, sorting, filtering

Does anyone know of a smart and easy way to accomplish this without the obvious and something like a very complex and cumbersome solution to iterate over all open windows and save each piece of information using the Preferences api? Thanks

+7
java swing settings preferences workspace
Feb 28 '12 at 10:23
source share
1 answer

In this case, the obvious java.util.prefs.Preferences solution is probably the right one. RCPrefs from this game is a simple example that demonstrates saving many data types, including enum . The exact implementation is highly dependent on the application. Although it is tiring, it does not have to be particularly difficult. For convenience, the example uses static methods; table frames and preferences are probably worth every class.

+7
Feb 28 '12 at 12:01
source share



All Articles