private boolean saveToFile(String filePath) {
        try {
            FileOutputStream saveFile = new FileOutputStream(filePath);
            ObjectOutputStream oos = new ObjectOutputStream(saveFile);
            // BufferedOutputStream save = new BufferedOutputStream(oos);
            oos.writeObject(bg.getPath());
            HashMap<Neuron, List<Edge>> allNeurons = neuronListGraph.getAllNeurons();
            for(Neuron n: allNeurons.keySet()){
                n.removeListerner();
                n.setCl(null);
            }
            for(Map.Entry<Line, Boolean> current:lines.entrySet()){
                Line line = current.getKey();
                line.prepareForSave();
            }
            filter=null;
            try{
                Image temp = bg.getBg();
                bg.setBg(null);
                oos.writeObject(neuronListGraph);
                bg.setBg(temp);
            }catch(NotSerializableException notInteresting){
                //error pga bgimage.bg försöker sparas, fast det inte behövs.
            }
            // oos.writeObject(neuronListGraph.getPairs());
        }catch(FileNotFoundException fnfe){
            JOptionPane.showMessageDialog(win,"Kunde inte hitta filen, eller så har den fel rättigheter");
        }catch (IOException ioe){
            JOptionPane.showMessageDialog(win,"Något io problem"+ioe.getMessage());
            ioe.printStackTrace();
        }catch (NullPointerException npe){
            npe.printStackTrace();
        }
        savedFilePath = filePath;
        hasChanges = false;
        return true;
    }