Java Example Program / Sample Source Code
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
class WindowStateListenerExample {
public static void main(String args[]) {
Frame frame = new Frame("WindowStateListenerExample");
frame.pack();
frame.setSize(new Dimension(350, 250));
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.addWindowStateListener(new WindowAdapter() {
public void windowStateChanged(WindowEvent e) {
System.out.println("windowStateChanged.");
}
});
}
} |
|
|