This is probably an extremely noob question, but is there a mouse event that I can code into my program in order that if you click the button, it will exit the program??
Say if I had this code to complete:
What would I put here please to make the button click close the frame and stop the program from running??
Any advise, or directions will be greatly appreciated and thanks in advance!!
Welcome to the ranch
Yes, System.exit(0); will successfully exit your program, but it is a bit vicious. What if you are threading, and the other thread is updating a file with your results? If you exit now, the other thread will be terminated too, maybe resulting in a corrupted file. Write an exit() method which terminates your application tidily and call that from the action performed method.
Alternatively: use the old AWT method of writing a listener which has a windowClosed method in. It might be a WindowListener and you can probably make your frame implement it.