Example usage for java.awt.event WindowAdapter WindowAdapter

List of usage examples for java.awt.event WindowAdapter WindowAdapter

Introduction

In this page you can find the example usage for java.awt.event WindowAdapter WindowAdapter.

Prototype

WindowAdapter

Source Link

Usage

From source file:FontPanel.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setTitle("NotHelloWorld2");
    frame.setSize(350, 200);//from   ww  w . jav  a  2  s  .  co  m
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    Container contentPane = frame.getContentPane();
    contentPane.add(new FontPanel());

    frame.show();
}

From source file:GradientPaintDemo2D.java

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

From source file:DashedRectangleDemo2D.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.j a  va  2  s  .  c  o m*/
        }
    });
    JApplet applet = new DashedRectangleDemo2D();
    f.getContentPane().add("Center", applet);
    applet.init();
    f.pack();
    f.setSize(new Dimension(300, 300));
    f.show();
}

From source file:NullLayoutPane.java

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

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

From source file:FillPolyPanel.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setTitle("FillPoly");
    frame.setSize(300, 200);// ww w.  ja  va2  s.  c  o  m
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    Container contentPane = frame.getContentPane();
    contentPane.add(new FillPolyPanel());

    frame.show();
}

From source file:IconPaint.java

public static void main(String[] args) {
    Image starImage = Toolkit.getDefaultToolkit().getImage(IconPaint.iconFile);

    IconPanel starPanel = new IconPanel(starImage);

    JFrame f = new JFrame("Icon");
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from   ww w  .  jav a2  s  .c o  m
        }
    });

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

From source file:GeneralPathOpenDemo2D.java

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

From source file:GeneralPathDemo2D.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 v a 2  s  .co  m
        }
    });
    JApplet applet = new GeneralPathDemo2D();
    f.getContentPane().add("Center", applet);
    applet.init();
    f.pack();
    f.setSize(new Dimension(300, 300));
    f.show();
}

From source file:Main.java

public static void main(String[] args) throws IOException {
    JFrame frame = new JFrame();
    frame.addWindowListener(new WindowListener() {
        @Override/*  w ww  .  j ava2  s  . com*/
        public void windowOpened(WindowEvent e) {
            System.out.println("JFrame has  been  made visible first  time");
        }

        @Override
        public void windowClosing(WindowEvent e) {
            System.out.println("JFrame is closing.");
        }

        @Override
        public void windowClosed(WindowEvent e) {
            System.out.println("JFrame is closed.");
        }

        @Override
        public void windowIconified(WindowEvent e) {
            System.out.println("JFrame is  minimized.");
        }

        @Override
        public void windowDeiconified(WindowEvent e) {
            System.out.println("JFrame is restored.");
        }

        @Override
        public void windowActivated(WindowEvent e) {
            System.out.println("JFrame is activated.");
        }

        @Override
        public void windowDeactivated(WindowEvent e) {
            System.out.println("JFrame is deactivated.");
        }
    });

    // Use the WindowAdapter class to intercept only the window closing event
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            System.out.println("JFrame is closing.");
        }
    });

}

From source file:SketchPanel.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setTitle("Sketch");
    frame.setSize(300, 200);/*from ww w.  j  av  a 2 s  . c o  m*/
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    Container contentPane = frame.getContentPane();
    contentPane.add(new SketchPanel());

    frame.show();
}