// Load application settings from .ini file private void setPreferences() { try { appSettings.load(new FileInputStream("appsettings.ini")); } catch (FileNotFoundException e) { } catch (IOException e) { } // By default, center window int width = Integer.parseInt(appSettings.getProperty("width", "640")); int height = Integer.parseInt(appSettings.getProperty("height", "480")); Rectangle screenBounds = getDisplay().getBounds(); int defaultTop = (screenBounds.height - height) / 2; int defaultLeft = (screenBounds.width - width) / 2; int top = Integer.parseInt(appSettings.getProperty("top", String.valueOf(defaultTop))); int left = Integer.parseInt(appSettings.getProperty("left", String.valueOf(defaultLeft))); getShell().setSize(width, height); getShell().setLocation(left, top); saveShellBounds(); }