public void saveGraphFile()
    {
      //==== Initialize the filechooser, using the user's home dir, or the last working dir
      if(this.currentDirectory.equals(""))
       {  this.fc = new JFileChooser();  }
      else
       {  this.fc = new JFileChooser(this.currentDirectory); }

      int returnVal = fc.showSaveDialog(this);

      if (returnVal == JFileChooser.APPROVE_OPTION) 
      {
        //==== Get the file object, and its filename
        File file = fc.getSelectedFile();
        final String fileName = file.getAbsolutePath();
        
        //==== if the file already exists, warn the user before overwriting
        if(file.exists())
        {
            //==== Create a frame with the message
            final JFrame overwriteMessage = new JFrame();
            overwriteMessage.setTitle("Overwrite file?");
            overwriteMessage.setLocationRelativeTo(fc);            
            JLabel title = new JLabel(" " + fileName);
            title.setFont(new Font("Tahoma", 0, 12));
            JLabel title2 = new JLabel(" File already exists, overwrite it?");
            title.setFont(new Font("Tahoma", 0, 12));
            
            //==== Create the button for overwriting the file
            JButton saveButton = new JButton();
            saveButton.setText("Yes");
            saveButton.setToolTipText("Overwrite file?");
            saveButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                  //TODO   ResultXML xml = new ResultXML();
                   // xml.writeFile(graph.getGraph(), fileName);
                    overwriteMessage.setVisible(false);
                }
            });
            //==== Create the button for not overwriting the file
            JButton noButton = new JButton();
            noButton.setText("No");
            noButton.setToolTipText("Overwrite file");
            noButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                    overwriteMessage.setVisible(false);
                }
            });
            
            //==== Add the buttons to a panel, and setup the layout
            JPanel buttons = new JPanel();
            GridLayout buttonLayout = new GridLayout(1,2);
            buttonLayout.addLayoutComponent("savebutton", saveButton);
            buttonLayout.addLayoutComponent("nobutton", noButton);
            buttons.add(saveButton);
            buttons.add(noButton);
            buttons.setLayout(buttonLayout);
            
            //==== Add the label, and the button panel, to another panel and setup the layout
            JPanel complete = new JPanel();
            GridLayout layout = new GridLayout(3,1);
            layout.addLayoutComponent("title", title);
            layout.addLayoutComponent("title2", title2);
            layout.addLayoutComponent("buttons", buttons);
            complete.add(title);
            complete.add(title2);
            complete.add(buttons);
            complete.setLayout(layout);

            Dimension d = new Dimension(450, 100);
            overwriteMessage.setSize(d);
            overwriteMessage.setContentPane(complete);
            overwriteMessage.setVisible(true);
        }
        
        //==== file doesn't already exist, so just write it        
        else
        {            
            //==== If it doesn't already have the .xml extension, add it
            String xmlExtension = ".xml";
            String fileName2 = fileName;
            if (!fileName.contains(xmlExtension))
            fileName2 = file.getAbsolutePath() + xmlExtension;
            
          // TODO     ResultXML xml = new ResultXML();
           // xml.writeFile(this.graph.getGraph(), fileName2);
        }
        this.currentDirectory = file.getPath();
      }
    }