Java WindowEvent.getWindow()
Syntax
WindowEvent.getWindow() has the following syntax.
public Window getWindow()
Example
In the following code shows how to use WindowEvent.getWindow() method.
//from w ww. ja va2 s . c o m
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
public class Main extends JFrame {
public Main() {
setDefaultCloseOperation(EXIT_ON_CLOSE);
enableEvents(java.awt.AWTEvent.WINDOW_EVENT_MASK);
}
protected void processWindowEvent(WindowEvent e) {
System.out.println(e.getWindow());
super.processWindowEvent(e); // Pass on the event
}
public static void main(String[] a) {
Main window = new Main();
window.setBounds(30, 30, 300, 300);
window.setVisible(true);
}
}
Home »
Java Tutorial »
java.awt.event »
Java Tutorial »
java.awt.event »