private void savePrefs() {
    SikuliIDE ide = SikuliIDE.getInstance();
    pref.setCaptureDelay((Double) _spnDelay.getValue());
    pref.setCaptureHotkey(_cap_hkey);
    pref.setCaptureHotkeyModifiers(_cap_mod);
    pref.setAutoNamingMethod(
        _radTimestamp.isSelected()
            ? UserPreferences.AUTO_NAMING_TIMESTAMP
            : _radOCR.isSelected()
                ? UserPreferences.AUTO_NAMING_OCR
                : UserPreferences.AUTO_NAMING_OFF);
    if (_old_cap_hkey != _cap_hkey || _old_cap_mod != _cap_mod) {
      ide.removeCaptureHotkey(_old_cap_hkey, _old_cap_mod);
      ide.installCaptureHotkey(_cap_hkey, _cap_mod);
    }
    pref.setCheckUpdate(_chkAutoUpdate.isSelected());

    pref.setExpandTab(_chkExpandTab.isSelected());
    pref.setTabWidth((Integer) _spnTabWidth.getValue());

    pref.setFontName((String) _cmbFontName.getSelectedItem());
    pref.setFontSize((Integer) _spnFontSize.getValue());

    Locale locale = (Locale) _cmbLang.getSelectedItem();
    pref.setLocale(locale);
    I18N.setLocale(locale);
  }
  private void updateFontPreview() {
    SikuliIDE ide = SikuliIDE.getInstance();
    Font font =
        new Font(
            (String) _cmbFontName.getSelectedItem(), Font.PLAIN, (Integer) _spnFontSize.getValue());

    SikuliCodePane codePane = SikuliIDE.getInstance().getCurrentCodePane();
    if (Utils.typeOfCodePane(codePane) == Utils.SikuliCodePaneType.SIKULI_PANE_TYPE_TEXT) {
      // preview only supported on text code panes
      SikuliTextPane textPane = (SikuliTextPane) (codePane.getComponent());
      textPane.setFont(font);
    }
  }
  private void loadPrefs() {
    SikuliIDE ide = SikuliIDE.getInstance();
    double delay = pref.getCaptureDelay();
    _spnDelay.setValue(delay);
    _old_cap_hkey = _cap_hkey = pref.getCaptureHotkey();
    _old_cap_mod = _cap_mod = pref.getCaptureHotkeyModifiers();
    setTxtHotkey(_cap_hkey, _cap_mod);
    switch (pref.getAutoNamingMethod()) {
      case UserPreferences.AUTO_NAMING_TIMESTAMP:
        _radTimestamp.setSelected(true);
        break;
      case UserPreferences.AUTO_NAMING_OCR:
        _radOCR.setSelected(true);
        break;
      case UserPreferences.AUTO_NAMING_OFF:
        _radOff.setSelected(true);
        break;
      default:
        Debug.error("Error in reading auto naming method preferences");
    }
    _chkAutoUpdate.setSelected(pref.getCheckUpdate());

    _chkExpandTab.setSelected(pref.getExpandTab());
    _spnTabWidth.setValue(pref.getTabWidth());
    initFontPrefs();
    initLangPrefs();
  }
 public PreferencesWin() {
   super(SikuliIDE._I("winPreferences"));
   initComponents();
   loadPrefs();
 }