Java Swing saves and loads workspace / settings
I have a Java Swing application that contains a stack of frames, and these frames mainly contain tables that display a large amount of data Since it is always cumbersome and time-consuming to arrange all windows and tables at startup, I want to implement the "workspace" function so that users can save preference settings and choose to automatically load the stored workspace at startup to display all windows and tables as previously saved Specifically, the settings I want to store in the workspace are:
>Active window (JFrame) and its size and position on the screen > table settings, including selected columns, column order, column width, sorting and filtering
Does anyone know a smart and simple way to achieve this, no obvious, and it seems to be a very complex and cumbersome solution, iterating over all open windows and saving each piece of information using the preferences API? thank you
Solution
In this case, the obvious solution is Java util. prefs. Preferences may be the right solution Rcprefs in this game is a simple example of how to save various data types, including enumeration The exact implementation is highly dependent on the application Although monotonous, it is not particularly complex For convenience, example uses a static method; Frame and table preferences may each be worth the lesson