Esempio n. 1
0
 // Save window location in appSettings hash table
 private void saveShellBounds() {
   // Save window bounds in app settings
   Rectangle bounds = getShell().getBounds();
   appSettings.setProperty("top", String.valueOf(bounds.y));
   appSettings.setProperty("left", String.valueOf(bounds.x));
   appSettings.setProperty("width", String.valueOf(bounds.width));
   appSettings.setProperty("height", String.valueOf(bounds.height));
 }
Esempio n. 2
0
 private void shellWidgetDisposed(DisposeEvent evt) {
   try {
     // Save app settings to file
     appSettings.store(new FileOutputStream("appsettings.ini"), "");
   } catch (FileNotFoundException e) {
   } catch (IOException e) {
   }
 }
Esempio n. 3
0
  // 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();
  }
Esempio n. 4
0
 private void exitMenuItemWidgetSelected(SelectionEvent evt) {
   try {
     // Save app settings to file
     appSettings.store(new FileOutputStream("appsettings.ini"), "");
   } catch (FileNotFoundException e) {
   } catch (IOException e) {
   }
   getShell().dispose();
   System.exit(1);
 }