if(!selectedFile.canWrite()){
if(selectedFile.exists() && !selectedFile.canWrite()){
            public void actionPerformed(ActionEvent e) {                JFileChooser chooser = new JFileChooser();                chooser.showSaveDialog(LoginPanel.this);                File selectedFile = chooser.getSelectedFile();                                if(selectedFile==null){                    JOptionPane.showMessageDialog(LoginPanel.this, "No favourites file selected", "Error", JOptionPane.ERROR_MESSAGE);                    return;                }                                if(!selectedFile.canWrite()){                    JOptionPane.showMessageDialog(LoginPanel.this, "Cannot write selected file", "Error", JOptionPane.ERROR_MESSAGE);                    return;                }                exportFavourites(selectedFile);                repaint();            }