No exit option if something is running

Posted by max on Stack Overflow See other posts from Stack Overflow or by max
Published on 2011-01-11T17:40:44Z Indexed on 2011/01/15 10:53 UTC
Read the original article Hit count: 149

Filed under:

How can I catch something going on if the user chooses the exit option from a menu? I mean I'd like to be able to manage the event of a user who is going to close the application but some activity is being performed so he/she shouldn't be able to exit.

Here's the code I wrote. In a nutshell :

  • recording is being performed --> user clicks exit --> WARNING "Process is running you can't do it"(The process goes on)

  • nothing is running --> user clicks exit --> application closes

Is it possible to solve the problem by just adding a few lines of code without having to rewrite the entire program?

thanks very much in advance.
MAX

exitAction = new AbstractAction("Exit") {

            public void actionPerformed(ActionEvent e) {

                System.exit(0);
            }
        };
        exitAction.putValue(Action.NAME, "Exit");
        // description 
        exitAction.putValue(Action.SHORT_DESCRIPTION, "Exit application");

© Stack Overflow or respective owner

Related posts about java