WindowAdapterTest.java Source code

Java tutorial

Introduction

Here is the source code for WindowAdapterTest.java

Source

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;

public class WindowAdapterTest {
    public static void main(String args[]) {
        JFrame frame = new JFrame("Window Listener");
        WindowListener listener = new WindowAdapter() {
            public void windowClosing(WindowEvent w) {
                System.exit(0);
            }
        };
        frame.addWindowListener(listener);
        frame.setSize(300, 300);
        frame.show();
    }
}