protected void save()
     {
//           System.out.println("show the file picker");
          JFileChooser filePicker = new JFileChooser();
          
//           filePicker.setFileHidingEnabled(false);
//           filePicker.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
          boolean exportData = false;
          File f = null;
          do
          {
               int returnValue = filePicker.showSaveDialog(parent);
               if (returnValue == filePicker.APPROVE_OPTION)
               {
                    f = filePicker.getSelectedFile();
                    String split[] = f.getName().split("\\.");
                    String newname = "";
                    if (split.length == 1)
                    {
     //                     System.out.println("no extension, so put one");
                         newname = split[0] + ".csv";
                    }
                    else if(!split[1].equals("csv") )
                    {
     //                     System.out.println("not csv, so put it");
                         newname = split[0] + ".csv";
                    }
                    else
                         newname = f.getName();
                    
                    newname = f.getParentFile() + System.getProperty("file.separator") + newname;
                    System.out.println("new name: " + newname);
                    //make a new file
                    
                    f = new File(newname);
                    if (f.exists())
                    {
//                          System.out.println("the file exists, ask them if they want to overwrite it");
                         int overwrite = JOptionPane.showConfirmDialog(null,"The file exists, overwrite?","File Exists",
                                                                       JOptionPane.YES_NO_OPTION);
                         System.out.println("overwrite: " + overwrite);
                         if(overwrite == 0)//overwrite the file, 0 = yes, 1 = no
                         {
                              exportData = true;
                         }
                         else //don't overwrite the file
                         {
                              exportData = false;
                         }
                    }
                    else
                    {
                         exportData = true;
                    }
               }
               //don't save the file at all
               else
               {
                    break;
               }
          }
          while(exportData == false);
          
          if (exportData)
          {
               try 
               {
                    FileWriter writer = new FileWriter(f);
                    BufferedWriter bufferedWriter = new BufferedWriter(writer);
                    PrintWriter out = new PrintWriter(bufferedWriter);
                    //loop through the tree
                    Csv combine = new Csv();
                    for(int i=0;i<data.size();i++)
                    {
                         String s = combine.combine(data.get(i));
//                          System.out.println("write this: " + s);
                         out.println(s);
                    }
                    out.close();
                    bufferedWriter.close();
                    writer.close();
               }
               catch (Exception fe)
               {
                    System.out.println("something happened, " + fe);
                    JOptionPane.showMessageDialog(parent,
                         "Can't write to\n" + fe,
                         "Export data error!",
                         JOptionPane.ERROR_MESSAGE
                    );
               }
          }//end write the file
     }//end save