Opening a JFrame window by calling an external class

I have a main menu that displays when the program is started.  It is located in the main method and class called    If you click the prizeCalculator button on this main menu, it opens the prizeCalculator JFrame window, which is located in an external class called  
There is a button on the prizeCalculator window that says "main menu" and when clicked, should close the prizeCalculator window and display the mainMenu window again.  

In the prizeCalculator external class, this line of code:
JFrame frame = mainMenuFrame();  
is giving the error that mainMenuFrame() is not recognized.  

Can you help me show the main menu frame once the "main menu" button is clicked on the prizeCalculator window?    Code and images are attached
 menu.tiff panel.tiff
//From the file: 

public class mainMenu
   public static void main(String[] args)
        JFrame frame = new mainMenuFrame();

class mainMenuFrame extends JFrame
    public mainMenuFrame()
        setTitle("Main Menu");
        JPanel panel = new mainMenuPanel();
        setSize(200, 200);

    private void centerWindow(Window w)
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension d = tk.getScreenSize();
        setLocation((d.width-w.getWidth())/2, (d.height-w.getHeight())/2);

class mainMenuPanel extends JPanel implements ActionListener

    private JButton     calculatorButton,
    public mainMenuPanel()
       setLayout(new GridBagLayout());

        // display panel
        JPanel displayPanel = new JPanel();
        displayPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
// and so on......

//from the file   This is the part that is telling the main menu button to show the main menu again

// main menu button
        mainMenuButton = new JButton("Main Menu");
                new ActionListener()
            public void actionPerformed(ActionEvent e)
            mainMenu object1 = new mainMenu();
            JFrame frame = mainMenuFrame();

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mick BarryJava DeveloperCommented:
>             JFrame frame = mainMenuFrame();

should be:

            JFrame frame = new mainMenuFrame();

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
deeayrianAuthor Commented:
Thank you that works perfectly!
But, I have a question.  How come when I needed to show the prizeCalculator JFrame from the main menu window, I had to create a new object, like this:
            prizeCalculator object1 = new prizeCalculator();
            JFrame frame = prizeCalculatorFrame();

But with this one I don't have to?
Mick BarryJava DeveloperCommented:
because in tht case the JFrame subclass is an inner class, thus you need to create an instance of the outer class
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.