WindowEvent
来源:互联网 发布:c语言课程设计小论文 编辑:程序博客网 时间:2024/06/07 07:43
import javax.swing.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
public class TestWindowEvent extends JFrame {
public TestWindowEvent() {
addWindowListener(new WindowListener() {
@Override
/**
* Handler for window-activated event
* Invoked when the window is set to be the user's
* active window, which means the window (or one of its
* subcomponents) will receive keyboard events
*/
public void windowActivated(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("Window activated");
}
@Override
/**
* Handler for window-closed event
* Invoked when a window has been closed as the result
* of calling dispose on the window
*/
public void windowClosed(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("Window Closed");
}
@Override
/**
* Handler for window-closing event
* Invoked when the user attempts to close the window
* from the window's system menu. If the program does not
* explicitly hide or dispose the window while processing
* this event, the window-closing operation will be cancelled.
*/
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("Window Closing");
}
@Override
/**
* Handler for window-deactivated event
* Invoked when a window is no longer the user's active
* window, which means that keyboard events will no longer
* be delivered to the window or its subcomponents.
*/
public void windowDeactivated(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("Window deactivated");
}
@Override
/**Handler for window-deiconified event
* Invoked when a window is changed from a minimized
* to a normal state.
*/
public void windowDeiconified(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("Window deiconified");
}
@Override
/**
* Handler for window-iconified event
* Invoked when a window is changed from a normal to a
* minimized state. For many platforms, a minimized window
* is displayed as the icon specified in the window's
* iconImage property
*/
public void windowIconified(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("Window Iconified");
}
@Override
/**
* Handler for window-opened event
* Invoked the first time a window is made visible.
*/
public void windowOpened(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("Window opened");
}
});
}
public static void main(String[] args) {
TestWindowEvent frame = new TestWindowEvent();
frame.setTitle("Test window event");
frame.setSize(300, 200);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
public class TestWindowEvent extends JFrame {
public TestWindowEvent() {
addWindowListener(new WindowListener() {
@Override
/**
* Handler for window-activated event
* Invoked when the window is set to be the user's
* active window, which means the window (or one of its
* subcomponents) will receive keyboard events
*/
public void windowActivated(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("Window activated");
}
@Override
/**
* Handler for window-closed event
* Invoked when a window has been closed as the result
* of calling dispose on the window
*/
public void windowClosed(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("Window Closed");
}
@Override
/**
* Handler for window-closing event
* Invoked when the user attempts to close the window
* from the window's system menu. If the program does not
* explicitly hide or dispose the window while processing
* this event, the window-closing operation will be cancelled.
*/
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("Window Closing");
}
@Override
/**
* Handler for window-deactivated event
* Invoked when a window is no longer the user's active
* window, which means that keyboard events will no longer
* be delivered to the window or its subcomponents.
*/
public void windowDeactivated(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("Window deactivated");
}
@Override
/**Handler for window-deiconified event
* Invoked when a window is changed from a minimized
* to a normal state.
*/
public void windowDeiconified(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("Window deiconified");
}
@Override
/**
* Handler for window-iconified event
* Invoked when a window is changed from a normal to a
* minimized state. For many platforms, a minimized window
* is displayed as the icon specified in the window's
* iconImage property
*/
public void windowIconified(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("Window Iconified");
}
@Override
/**
* Handler for window-opened event
* Invoked the first time a window is made visible.
*/
public void windowOpened(WindowEvent e) {
// TODO Auto-generated method stub
System.out.println("Window opened");
}
});
}
public static void main(String[] args) {
TestWindowEvent frame = new TestWindowEvent();
frame.setTitle("Test window event");
frame.setSize(300, 200);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
0 0
- WindowEvent
- 第11章 GUI 13 WindowEvent and 匿名类
- 【Yii】挂件widget
- Java文件删除所有注释 工具+eclipse批量替换(亲测好使)
- 【Yii】CDataProvider
- 如何在java环境下使用feature option(如何添加FeatureOption.xxx)
- leetcode第一刷_Generate Parentheses
- WindowEvent
- 【Yii】url路由
- 虚拟地球原理与实现
- 编程语言系列(二)--C++语言基础知识点总结
- 【Yii】日志
- UDP协议发送对象
- Android的CursorLoader用法小结
- win8如何移动用户的 Documents and Settings 文件夹
- Why there are no job running on hadoop