confirm exit netbeans desktop apps

do this..

    app.addExitListener(new ExitListener() {
        public boolean canExit(EventObject e) {
            return formWindowClosing();
        }
        public void willExit(EventObject e){
            
        }
    });

...

private boolean formWindowClosing() {
    if(JOptionPane.showConfirmDialog(this.getFrame(), "Exit Application?", "Confirm Exit", JOptionPane.YES_NO_OPTION) ==
            JOptionPane.YES_OPTION){
        if (runner != null)
            if ( runner.isAlive())
                runner.stopProcess();
        return true;

    }
    return false;
}

And the world shines bright again..

Discuss - 2 Comments

  • sennyApr 25th, 2010

    hah? apaan itu? sejenis mantra biar dapet jodohkah?

  • havbanMay 4th, 2010

    @senny
    🙂

    itu adalah jampi2 penolak jodoh.. huahuahua…