JFrame.dispose() vs System.exit()
What is the difference between these two methods - System.exit() and JFrame.dispose() ? If we want to close a Java Swing application when a button is clicked, which method should I use? System.exit(); causes the Java VM to terminate completely. JFrame.dispose(); causes the JFrame window to be destroyed and cleaned up by the operating system. According to the documentation , this can cause the Java VM to terminate if there are no other Windows available, but this should really just be seen as a side effect rather than the norm. The one you choose really depends on your situation. If you want to