File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JFrame Help Please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFrame Help Please" Watch "JFrame Help Please" New topic

JFrame Help Please

ben williamson

Joined: Apr 08, 2008
Posts: 5
Hey all,

Basically i havn't programmed for quite a while now and am trying to get back into it, i am trying to make a little application with a JFrame, and here is the code I have produced...

Basically, I have created a little JFrame with some layout and 2 main buttons...and this is in a file called I want to do though, is when the 'New' Button is pressed, i would like it to call another seperate class i have created, in that java file it is like this one, but with different buttons and all....

I think this is really simple to achieve, i just simply cannot remmeber what to do, if anyone can help it would be superb! Also, when the 'Exit' button is pushed, what is the correct syntax to close the JFrame, I need to catch back up on this but im starting to get back into it.

Mank Thanks,

ben williamson

Joined: Apr 08, 2008
Posts: 5

I have managed to solve this, but i stil cannot get the first window to close then the second is created, anyone know how to do this??

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

You'll need to call frame.dispose() on the frame you want to make go away. That said, the better approach would be to simply swap out your JPanel with a new JPanel that contains all the components you want.

GenRocket - Experts at Building Test Data
I agree. Here's the link:
subject: JFrame Help Please
It's not a secret anymore!