public void saveFile() {

        if (simulator == null || !simulator.isAlive()) {
            FileManager fileManager = new FileManager();
            jFileChooser1 = new javax.swing.JFileChooser(defaultPath);

            int option = this.jFileChooser1.showSaveDialog(this);
            if (option == JFileChooser.APPROVE_OPTION) {
                if (this.jFileChooser1.getSelectedFile() != null) {
                    File file = this.jFileChooser1.getSelectedFile();
                    try {
                        fileManager.generateXML(this.canvas.getFigures(), file);
                    } catch (ParserConfigurationException ex) {
                        Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (TransformerConfigurationException ex) {
                        Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (TransformerException ex) {
                        Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
                    }

                }
            }
        }
    }