Java捕获其他窗口事件
package com.han; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import javax.swing.JFrame; /** * 捕获其他窗口事件 * @author HAN * */ public class WindowEvent_3 extends JFrame { /** * */ private static final long serialVersionUID = 9040264048222645786L; public WindowEvent_3() { // TODO Auto-generated constructor stub addWindowListener(new WindowListener() { @Override public void windowOpened(WindowEvent e) { // TODO Auto-generated method stub System.out.println("窗口被打开!"); } @Override public void windowClosing(WindowEvent e) { // TODO Auto-generated method stub System.out.println("窗口将要被关闭!"); } @Override public void windowClosed(WindowEvent e) { // TODO Auto-generated method stub System.out.println("窗口已经被关闭!"); } @Override public void windowIconified(WindowEvent e) { // TODO Auto-generated method stub System.out.println("窗口被图标化!"); } @Override public void windowDeiconified(WindowEvent e) { // TODO Auto-generated method stub System.out.println("窗口被非图标化!"); } @Override public void windowActivated(WindowEvent e) { // TODO Auto-generated method stub System.out.println("窗口被激活!"); } @Override public void windowDeactivated(WindowEvent e) { // TODO Auto-generated method stub System.out.println("窗口不再处于激活状态!"); } }); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub WindowEvent_3 frame = new WindowEvent_3(); frame.setTitle("捕获其他窗口事件"); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setBounds(0, 0, 300, 100); } }
posted on 2012-07-12 05:25 java课程设计例子 阅读(238) 评论(0) 编辑 收藏 举报
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步