Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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
Author

Java

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
Sheriff

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: 15299
    
    6

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java
 
Similar Threads
NetBeans IDE 5.5
Working with multiple frames
Unloading a frame
Closing a Frame in Java
how to close or exit of one of two opened windows?