public void saveModel() {
    try {
      if (m_fileChooser == null) {
        // i.e. after de-serialization
        m_fileChooser = 
          new JFileChooser(new File(System.getProperty("user.dir")));
        ExtensionFileFilter ef = new ExtensionFileFilter("model", "Serialized weka clusterer");
      m_fileChooser.setFileFilter(ef);
      }
      int returnVal = m_fileChooser.showSaveDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        File saveTo = m_fileChooser.getSelectedFile();
        String fn = saveTo.getAbsolutePath();
        if (!fn.endsWith(".model")) {
          fn += ".model";
          saveTo = new File(fn);
        }
        ObjectOutputStream os = 
          new ObjectOutputStream(new BufferedOutputStream(
                                                          new FileOutputStream(saveTo)));
        os.writeObject(m_Clusterer);
        if (m_trainingSet != null) {
          Instances header = new Instances(m_trainingSet, 0);
          os.writeObject(header);
        }
        os.close();
        if (m_log != null) {
          m_log.logMessage("[Clusterer] Saved clusterer " + getCustomName());
        }
      }
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(Clusterer.this,
                                    "Problem saving clusterer.\n",
                                    "Save Model",
                                    JOptionPane.ERROR_MESSAGE);
      if (m_log != null) {
        m_log.logMessage("[Clusterer] Problem saving clusterer. " 
            + getCustomName() + ex.getMessage());
      }
    }
  }