@Test
  public void testSaveLoad() throws FileNotFoundException, IOException {
    System.out.println("---  testSaveLoad...");
    XMLEncoder xmlEncoder = null;
    FileOutputStream fos = null;
    BufferedOutputStream bos = null;

    File f = new File("testProjects/TEMP_PROJECTS/Test.ser");

    System.out.println("Saving to: " + f.getCanonicalPath());

    fos = new FileOutputStream(f);
    bos = new BufferedOutputStream(fos);
    xmlEncoder = new XMLEncoder(bos);

    // Metric m = Metric.PATH_LENGTH_FROM_ROOT;
    Object o1 = pg1;

    System.out.println("Pre: " + o1);

    // ProximalPref p = ProximalPref.MOST_PROX_AT_0;

    xmlEncoder.writeObject(o1);
    xmlEncoder.close();

    FileInputStream fis = new FileInputStream(f);
    BufferedInputStream bis = new BufferedInputStream(fis);
    XMLDecoder xd = new XMLDecoder(bis);

    Object o2 = xd.readObject();

    System.out.println("Post: " + o2);

    assertEquals(o2, o1);
  }
 public void save() {
   if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
     try {
       File file = chooser.getSelectedFile();
       XMLEncoder encoder = new XMLEncoder(new FileOutputStream(file));
       encoder.writeObject(frame);
       encoder.close();
     } catch (IOException e) {
       JOptionPane.showMessageDialog(null, e);
     }
   }
 }
 /**
  * Save <code>PanelModel</code> and its supporting classes as a XML stream using the <code>
  * XMLEncoder</code>.
  *
  * @param os OutputStream
  */
 public void saveToXML(OutputStream os) {
   XMLEncoder xe = new XMLEncoder(os);
   xe.writeObject(this);
   xe.close();
 }