I have a gui java program that count the number of files (if any) in a folder and store their names in an array for processing. In the case when no files are available to process, I want to display a joptionpane with the message " No files are available to process. Please click the exit button to exit the system ".

How can I exit the system when the user click the button of the joptionpane?
Something like

```
if (array.length == 0){
    JOptionPane.show .......
    {
        System.exit(0);
    }
}

```