Example usage for javax.swing JFrame addWindowListener

List of usage examples for javax.swing JFrame addWindowListener

Introduction

In this page you can find the example usage for javax.swing JFrame addWindowListener.

Prototype

public synchronized void addWindowListener(WindowListener l) 

Source Link

Document

Adds the specified window listener to receive window events from this window.

Usage

From source file:Main.java

public static void main(String... args) {
    JFrame frame = new JFrame();

    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            int result = JOptionPane.showConfirmDialog(frame, "Do you want to Exit ?", "Exit Confirmation : ",
                    JOptionPane.YES_NO_OPTION);
            if (result == JOptionPane.YES_OPTION)
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            else if (result == JOptionPane.NO_OPTION)
                frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        }/*w w w .  j  a  va2s.  c  om*/
    });

    frame.setSize(300, 300);
    frame.setVisible(true);

}

From source file:LabelForComboBox.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from   www  . ja v  a  2 s .  com*/
        }
    });
    f.getContentPane().add(new LabelForComboBox());
    f.pack();
    f.setSize(new Dimension(300, 200));
    f.show();

}

From source file:BorderLayoutPane.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from w w  w.  ja  va 2  s .  com
        }
    });

    f.setContentPane(new BorderLayoutPane());
    f.pack();
    f.setVisible(true);
}

From source file:GradientPaintDemo.java

public static void main(String s[]) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from w ww . ja va  2  s  . com*/
        }
    });
    GradientPaintDemo p = new GradientPaintDemo();
    f.getContentPane().add("Center", p);
    p.init();
    f.pack();
    f.setSize(new Dimension(250, 250));
    f.show();
}

From source file:BasicStrokeDemo.java

public static void main(String s[]) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from  www  .  j  a  va  2s.co m
        }
    });
    BasicStrokeDemo p = new BasicStrokeDemo();
    f.getContentPane().add("Center", p);
    p.init();
    f.pack();
    f.setSize(new Dimension(250, 250));
    f.show();
}

From source file:ThickStrokeDemo.java

public static void main(String s[]) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);// www  .  j a va 2s .  c om
        }
    });
    ThickStrokeDemo p = new ThickStrokeDemo();
    f.getContentPane().add("Center", p);
    p.init();
    f.pack();
    f.setSize(new Dimension(250, 250));
    f.show();
}

From source file:DashedStrokeDemo.java

public static void main(String s[]) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);// ww w. j av a 2 s  . co m
        }
    });
    DashedStrokeDemo p = new DashedStrokeDemo();
    f.getContentPane().add("Center", p);
    p.init();
    f.pack();
    f.setSize(new Dimension(250, 250));
    f.show();
}

From source file:JTextAreaDemo.java

public static void main(String[] args) {
    JFrame frame = new JTextAreaDemo();
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from  w ww  .  ja  v  a 2s.  co m
        }
    });

    frame.pack();
    frame.setVisible(true);
}

From source file:GridLayoutPane.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from  w  ww  .j  a  v  a 2s .  com
        }
    });

    frame.getContentPane().add(new GridLayoutPane(), BorderLayout.CENTER);
    // Finally, set the size of the main window, and pop it up.
    frame.setSize(600, 400);
    frame.setVisible(true);
}

From source file:TexturePaintDemo.java

public static void main(String s[]) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//www  .j  a  v  a2 s .  com
        }
    });
    TexturePaintDemo p = new TexturePaintDemo();
    f.getContentPane().add("Center", p);
    p.init();
    f.pack();
    f.setSize(new Dimension(250, 250));
    f.show();
}