/** * Tries to load/restore the window state of the given window. * * @param aNamespace the namespace to use for the window state; * @param aProperties the properties to read from; * @param aWindow the window to load the state for. */ public static void loadWindowState(final Preferences aProperties, final Window aWindow) { // Special case: for FileDialog/JFileChooser we also should restore the // properties... loadFileDialogState(aProperties, aWindow); try { final int xPos = aProperties.getInt("winXpos", -1); final int yPos = aProperties.getInt("winYpos", -1); if ((xPos >= 0) && (yPos >= 0)) { aWindow.setLocation(xPos, yPos); } } catch (NumberFormatException exception) { // Ignore... } if (isNonResizableWindow(aWindow)) { // In case the window cannot be resized, don't restore its width & // height... return; } try { final int width = aProperties.getInt("winWidth", -1); final int height = aProperties.getInt("winHeight", -1); if ((width >= 0) && (height >= 0)) { aWindow.setSize(width, height); } } catch (NumberFormatException exception) { // Ignore... } }