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:FilledGeneralPath.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 w  w . ja v  a2s  .  c  o m*/
        }
    });
    JApplet applet = new FilledGeneralPath();
    f.getContentPane().add("Center", applet);
    applet.init();
    f.pack();
    f.setSize(new Dimension(300, 300));
    f.show();
}

From source file:ColorComboRenderer.java

public static void main(String[] a) {
    JComboBox cbColor = new JComboBox();
    int[] values = new int[] { 0, 128, 192, 255 };
    for (int r = 0; r < values.length; r++)
        for (int g = 0; g < values.length; g++)
            for (int b = 0; b < values.length; b++) {
                Color c = new Color(values[r], values[g], values[b]);
                cbColor.addItem(c);//from w w  w  .  j  a  v  a2 s  . com
            }
    cbColor.setRenderer(new ColorComboRenderer());

    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    f.getContentPane().add(cbColor);
    f.pack();
    f.setSize(new Dimension(300, 80));
    f.show();

}

From source file:LineDemo2D.java

public static void main(String s[]) {
    JFrame f = new JFrame("ShapesDemo2D");
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from  w  ww.  j  a v a2  s  .c o m*/
        }
    });
    JApplet applet = new LineDemo2D();
    f.getContentPane().add("Center", applet);
    applet.init();
    f.pack();
    f.setSize(new Dimension(300, 300));
    f.show();
}

From source file:FrameClose2.java

public static void main(String[] args) {
    JFrame mainFrame = new JFrame();

    // Exit app when frame is closed.
    mainFrame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent ev) {
            System.exit(0);//from   w  w w  .j ava  2 s.  c o  m
        }
    });

    mainFrame.setSize(320, 240);
    mainFrame.setVisible(true);
}

From source file:TextLayoutDemo.java

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

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

From source file:Containers.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*  w w w .j a va 2  s  .c  o m*/
        }
    });

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

From source file:FontPaint.java

public static void main(String[] args) {
    FontPanel starPanel = new FontPanel();

    JFrame f = new JFrame("Font");
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from   w  ww. j  a  v  a  2s  . co  m*/
        }
    });

    f.getContentPane().add(starPanel, BorderLayout.CENTER);
    f.setSize(new Dimension(550, 200));
    f.setVisible(true);
}

From source file:SVGCanvasDemo.java

public static void main(String args[]) {
    JFrame frame = new JFrame("JSVGCanvas Demo");
    frame.setSize(400, 400);/* w  w w.j  a v  a  2  s.  c  o m*/

    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent ev) {
            System.exit(0);
        }
    });

    new SVGCanvasDemo(frame);
}

From source file:AntiAlias.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*  w  w w  .j a v a  2  s .  c  om*/
        }
    });
    f.setContentPane(new AntiAlias());
    f.setSize(400, 400);
    f.setVisible(true);
}

From source file:DynamicHookupTest.java

public static void main(String[] args) {
    JFrame f = new DynamicHookupTest();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            System.exit(0);/* w  ww  .  j a v a2  s.  c  om*/
        }
    });
    f.setSize(150, 150);
    f.setVisible(true);
}