The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

JButton open new window

Been sitting here at my computer for about 13 hours and I think my eyes are bleeding.
I found a little gui editor I love called GuiGenie.
It works perfect for creating the window with the buttons and all that good stuff.
The problem is i want to click a button in my first menu and have it open my other menu i made.
I just starting programming 4 weeks ago so I'm a complete noob.
I have a feeling its messing up because of the main methods but I have no idea and 13 hours of sitting here trying millions of things is making me go crazy : )
here is what i got so far

If anyone could help I would appreciate it greatly!!
I have a lot of respect for you pros out there because if you are a pro at this, you are probably smarter than 99.9% of the world.
This stuff hurts my brain.

Re: JButton open new window

1. for the class with the JButton put "implements MouseListener" after it says "extends JPanel" and import the mouse listener class
2. in the constructor write, this.addMouseListener(this); and for your button write myButton.addMouseListener(this); replacing myButton with whatever yours is called.
3. then in the actionPerformedMouseClicked method that you must have because you're implementing MouseListener, have a check for the button. to see if its the one you want to make open the other menu, would look something like this, "if(e.getComponent().equals(myButton)) //open menu;
4. Not sure if you want a whole new window or just to replace whats in your JFrame, if you want a whole new window in the if statement mentioned above instantiate the class that extends JFrame holds your other menu, it would look something like the first one. If you want the Panel to be switched just change what panel is displayed in the original JFrame