码迷,mamicode.com
首页 > 编程语言 > 详细

【JAVA语言程序设计基础篇】--事件驱动程序设计--窗口事件

时间:2016-08-15 20:51:43      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:


对窗口进行操作,将操作步骤显示在控制台


package chapter16;

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

import javax.swing.JFrame;

@SuppressWarnings("serial")
public class TestWindowEvent extends JFrame {
		
	public TestWindowEvent (){
		addWindowListener(new WindowListener() {//匿名内部类
			
			@Override
			public void windowOpened(WindowEvent e) {
				System.out.println("打开");
			}
			
			@Override
			public void windowIconified(WindowEvent e) {
				System.out.println("最小化");
			}
			
			@Override
			public void windowDeiconified(WindowEvent e) {
				System.out.println("最大化");
			}
			
			@Override
			public void windowDeactivated(WindowEvent e) {
				System.out.println("deactivate");
			}
			
			@Override
			public void windowClosing(WindowEvent e) {
				System.out.println("正在关闭");
			}
			
			@Override
			public void windowClosed(WindowEvent e) {
				System.out.println("closed");
			}
			
			@Override
			public void windowActivated(WindowEvent e) {
				System.out.println("activate");
			}
		});
	}
	public static void main(String[] args) {
		JFrame frame = new TestWindowEvent();
		frame.setTitle("loancalculator");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setLocationRelativeTo(null);
		frame.setVisible(true);
		frame.pack();
		frame.setSize(300, 300);
	}

}




对窗口进行操作

显示在控制台中


技术分享

【JAVA语言程序设计基础篇】--事件驱动程序设计--窗口事件

标签:

原文地址:http://blog.csdn.net/qq_24653023/article/details/52214449

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!