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 Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Java" Watch "Java" New topic


Richard Mendoza
Ranch Hand

Joined: Feb 26, 2003
Posts: 48
I have a command button named CLOSE in my swing frame. I want to close a swing frame after clicking the command button named CLOSE. What shall I command in the actionPerformed() method?
Richard Teston
Ranch Hand

Joined: Feb 12, 2002
Posts: 89
Ei, Pare mali ka ng topic na i post, doon ka dapat sa Swing/AWT/JFC, anyway answering your question use System.exit(0) under actionPerformed method.

The Code is the Programmer
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
Moving to Swing/AWT/JFC forum,...

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

System.exit(0) will indeed close the frame, however, this will also close ALL your frames if you have any others running within the same application.
If you just need to close a frame without actually exiting the application, use myFrame.dispose() method.

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