Question : NetBeans - Added WindowsListener, but program won't exit anymore

Hi, just learning NetBeans at the moment and am trying to learn how to use the WindowsListeners.  I accomplished my goal to make it do something at startup but I can't get the program to exit.... i tried System.exit(0) but that's not working.... did some googling and added:

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

but that doesn't work either

i know it's something simple but i can't figure it out
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
import java.awt.event.*;
import javax.swing.JFrame;   
public class Driver extends JFrame implements WindowListener {  
    /** Creates new form Driver */
    public Driver() {
        initComponents();
        addWindowListener(this);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }   
    @SuppressWarnings("unchecked")  
              
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Driver().setVisible(true); 
            }
        });
    }   
    public void windowClosing(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }   
    public void windowClosed(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }   
    public void windowIconified(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }   
    public void windowDeiconified(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }   
    public void windowDeactivated(WindowEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }   
    public void windowActivated(WindowEvent e) {
        System.out.println("test");
    }   
    public void windowOpened(WindowEvent e) {
        System.out.println("test2");
    }   
    // Variables declaration - do not modify                     
    // End of variables declaration                    
}

Answer : NetBeans - Added WindowsListener, but program won't exit anymore

>         throw new UnsupportedOperationException("Not supported yet.");

remove all those throwing of exceptions

if you use the first method you can remove the listener entirely
Random Solutions  
 
programming4us programming4us