public void saveMap(){
        browser.setSelectedFile(new File(mapName));
        browser.setDialogTitle("Save Map File");
        browser.setCurrentDirectory(new File(directory));
        browser.setFileFilter(fileFormats);
        int actionDialog = browser.showSaveDialog(null);
        switch (actionDialog) {
            case JFileChooser.APPROVE_OPTION:
                if (browser.getSelectedFile().exists()){
                    int actionDialog2 = JOptionPane.showConfirmDialog(null,"Replace existing file?");
                    if (actionDialog2 == JOptionPane.NO_OPTION){ saveMap(); }
                    else if (actionDialog2 == JOptionPane.YES_OPTION){
                        mapName = browser.getSelectedFile().toString();
                        quickSave(true);
                    }
                    else if (actionDialog2 == JOptionPane.CANCEL_OPTION){ }
                }
                else{
                    mapName = browser.getSelectedFile().toString();
                    quickSave(true);
                }
                if (exitAfterSave) System.exit(0);
            break;
            case JFileChooser.CANCEL_OPTION:

            break;
            case JFileChooser.ERROR_OPTION:

            break;
        }
    }