Can someone please explaon the difference of the above action listeners?? it seems like they both do the same thing - that is close a frame/window.


big help thank you

Recommended Answers

All 2 Replies

dispose() just gets rid of a swing object. If you have two windows and dispose() one of them, the other will still be there.
System.exit() terminates the whole program and closes all its windows.

dispose frees resources used by class and exit forces all threads of the program to terminate immediately, common use if you get an error in your program and what to terminate it you use System.exit(-1), -1 indicates that some error occurred, if no error occurred that would be exit(0)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.