Search code examples
javaeventsbuttonshutdownactionlistener

How do I shutdown my program with a JButton ActionListener?


I have a button, and a buttonhandler(ActionEvent) for it. Now, I want to make it so that, when you click the button, your program shuts down. How would I go about doing this? My buttonhandler code:

class ButtonHandler implements ActionListener{
    public void actionPerformed( ActionEvent e){

    }
}

So I basicly need to shutdown the whole JFrame.


Solution

  • If you are shutting down the entire program, you can use System.exit().