private void SaveNotesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveNotesActionPerformed
// This allows you to choose the file save location:
        File outFile;
        FileWriter fw;
        BufferedWriter bw;

        String Notes = NotesTf.getText();
        //@refernce http://stackoverflow.com/questions/13440566/saving-file-in-same-format-as-textarea-prob
        JFileChooser chooser = new JFileChooser();
        chooser.setCurrentDirectory(new File("./"));
        int actionDialog = chooser.showSaveDialog(this);
        if (actionDialog == JFileChooser.APPROVE_OPTION) {
            try {
                outFile = new File("MathsNotes.txt");
                fw = new FileWriter(outFile, true);
                bw = new BufferedWriter(fw);
                if (Notes == null) {
                    return;
                }
                if (outFile.exists()) {
                    actionDialog = JOptionPane.showConfirmDialog(this,
                            "Replace existing file?");
                    if (actionDialog == JOptionPane.NO_OPTION) {
                        return;
                    }
                }
                bw = new BufferedWriter(new FileWriter(outFile));
                bw.write(Notes);
                bw.close(); // after first checking if null
                JOptionPane.showMessageDialog(null, "Your notes have been saved successfully");
                //File fileName = new File(chooser.getSelectedFile( ) + "" );

            } catch (IOException e) {
                System.out.println("Error writing to file: " + e);
            }
        }
    }//GEN-LAST:event_SaveNotesActionPerformed