Java Cookbook Recipe 14.x - Remember GUI location and size

Problem

You want your GUI to remember its location and/or size when the user restarts the application.

Solution

Set a ComponentListener on the main Window which will call you back to fetch the new size and/or location; save the value in Preferences (See XX); restore them from Preferences at application startup time.

Discussion

This is a basic feature that users expect in a production GUI.

How ... (see UtilGUI.monitor method)

See Also

Swing Hacks for more preferences stuff.