aspose file tools
The moose likes Swing / AWT / SWT and the fly likes Java Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply 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
Ranch Hand

Joined: Jul 11, 2001
Posts: 15230

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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Java
 
Similar Threads
Working with multiple frames
Unloading a frame
NetBeans IDE 5.5
Closing a Frame in Java
how to close or exit of one of two opened windows?