Accessing a String field in one JFrame from another JFrame

I am writing a program in which one JFrame needs to access a string field of another. I looked on here for about 2 hours and found something that worked for other people that involved a JOptionPane and attempted it in my own program. However when I run the program and click the button that opens the program, the program errors out even though the call to JOptionPane is the exact same as the one in other examples.

With the main problem area being here:

if(event.getSource() == newCipher) {

        nameLabel.setText("Work");

        MakeCipherGUI makeCipher = new MakeCipherGUI();
        int result = JOptionPane.showConfirmDialog(null, makeCipher,
                "Edit Player JOptionPane", JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.PLAIN_MESSAGE);

    }

Here is the code for the JFrame that calls the other JFrame if it helps:

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

public class MainMenu extends JFrame implements ActionListener{

    private JLabel messageLabel;
    private JLabel nameLabel;
    private JButton encrypt;
    private JButton decrypt;
    private JButton newCipher;
    private JButton selectCipher;

    private String selected;

    public MainMenu(){
        super("Main Menu");

        nameLabel = new JLabel("Name: No selected ciphers");
        add(nameLabel);

        messageLabel = new JLabel("Message: No selected ciphers");
        add(messageLabel);

        encrypt = new JButton("Encrypt");
        add(encrypt);
        encrypt.addActionListener(this);

        decrypt = new JButton("Decrypt");
        add(decrypt);
        decrypt.addActionListener(this);

        newCipher = new JButton("Make new cipher");
        add(newCipher);
        newCipher.addActionListener(this);

        selectCipher = new JButton("Select existing cipher");
        add(selectCipher);
        selectCipher.addActionListener(this);

        setLayout(new GridLayout(6,1,10,10));

    }

    public void actionPerformed(ActionEvent event) {

        if(event.getSource() == encrypt) {
            if(CipherDict.isInCae(selected)) {
                Caeser c = CipherDict.getKeyCae(selected);
                c.encrypt();
                nameLabel.setText("Name: " + selected);
                messageLabel.setText("Message: " + c.toString());
            }
            if(CipherDict.isInSub(selected)) {
                Substitution s = CipherDict.getKeySub(selected);
                s.encrypt();
                nameLabel.setText("Name: " + selected);
                messageLabel.setText("Message: " + s.toString());
            }
            if(CipherDict.isInRot(selected)) {
                Rotor r = CipherDict.getKeyRot(selected);
                r.encrypt();
                nameLabel.setText("Name: " + selected);
                messageLabel.setText("Message: " + r.toString());
            }
        }

        if(event.getSource() == decrypt) {
            if(CipherDict.isInCae(selected)) {
                Caeser c = CipherDict.getKeyCae(selected);
                c.decrypt();
                nameLabel.setText("Name: " + selected);
                messageLabel.setText("Message: " + c.toString());
            }
            if(CipherDict.isInSub(selected)) {
                Substitution s = CipherDict.getKeySub(selected);
                s.decrypt();
                nameLabel.setText("Name: " + selected);
                messageLabel.setText("Message: " + s.toString());
            }
            if(CipherDict.isInRot(selected)) {
                Rotor r = CipherDict.getKeyRot(selected);
                r.decrypt();
                nameLabel.setText("Name: " + selected);
                messageLabel.setText("Message: " + r.toString());
            }
        }

        if(event.getSource() == newCipher) {

            nameLabel.setText("Work");

            MakeCipherGUI makeCipher = new MakeCipherGUI();
            int result = JOptionPane.showConfirmDialog(null, makeCipher,
                    "Edit Player JOptionPane", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE);

        }
    }

}

The code for the JFrame that gets called is here if it helps:

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;



public class MakeCipherGUI extends JFrame implements ActionListener{

    private JTextField messageField;
    private JTextField nameField;
    private JTextField keyField;
    private JButton enterButton;
    private JRadioButton cea;
    private JRadioButton sub;
    private JRadioButton rot;
    private String selectedName;


    public MakeCipherGUI(){
        super("Make a Cipher");

        GridBagLayout grid = new GridBagLayout();
        GridBagConstraints gbc = new GridBagConstraints();
        setLayout(grid);

        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridx = 0;
        gbc.gridy = 0;
        nameField = new JTextField("Enter a name for the cipher to be saved for future use");
        add(nameField,gbc);

        gbc.gridx = 1;
        gbc.gridy = 0;
        cea = new JRadioButton("Caeser");
        add(cea,gbc);

        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridx = 0;
        gbc.gridy = 1;
        messageField = new JTextField("Your message goes here");
        add(messageField,gbc);

        gbc.gridx = 1;
        gbc.gridy = 1;
        sub = new JRadioButton("Substitution");
        add(sub,gbc);

        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridx = 0;
        gbc.gridy = 2;
        keyField = new JTextField("Enter a key for the cipher");
        add(keyField,gbc);

        gbc.gridx = 1;
        gbc.gridy = 2;
        rot = new JRadioButton("Rotor");
        add(rot,gbc);

        gbc.fill = GridBagConstraints.HORIZONTAL;

        ButtonGroup ciphers = new ButtonGroup();
        ciphers.add(cea);
        ciphers.add(sub);
        ciphers.add(rot);


        gbc.gridx = 0;
        gbc.gridy = 3;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridwidth = 2;
        enterButton = new JButton("Enter");
        add(enterButton,gbc);
        enterButton.addActionListener(this);

    }

    public void actionPerformed(ActionEvent event) {

        String name = nameField.getText();
        String message = messageField.getText();
        JFrame f = new JFrame();

        if(name.equals("Enter a name for the cipher to be saved for future use")) {
            JOptionPane.showMessageDialog(f, "Please enter a name","Error",JOptionPane.ERROR_MESSAGE);
            return;
        }

        if(message.equals("Your message goes here")) {
            int a = JOptionPane.showConfirmDialog(f, "Are you sure you want to use the default message?");
            if(a == JOptionPane.CANCEL_OPTION || a == JOptionPane.NO_OPTION) {
                return;
            }
        }



        if(cea.isSelected()) {
            int key = -1;
            try {
                key = Integer.parseInt(keyField.getText());
                CipherDict.addCae(name, new Caeser(message,key));
                selectedName = name;
                this.dispose();

            }

            catch(NumberFormatException e) {
                JOptionPane.showMessageDialog(f,"Please enter an integer in the key field.","Error",JOptionPane.ERROR_MESSAGE);
            }

        }

        if(sub.isSelected()) {
            CipherDict.addSub(name,new Substitution(message,keyField.getText()));
            selectedName = name;
            this.dispose();

        }

        if(rot.isSelected()) {
            CipherDict.addRot(name,new Rotor(message,keyField.getText()));
            selectedName = name;
            this.dispose();

        }

    }

    public String getSelected() {
        return selectedName;
    }

}