⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mvc2ctrl.java

📁 mvc三层软件结构实例
💻 JAVA
字号:
package com.sitinspring;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * 控制类
 * 
 * @author sitinspring(junglesong@gmail.com)
 * 
 * @date 2007-11-5
 */
public class Mvc2Ctrl {
	private Mvc2View view;

	private Mvc2Model model;

	public Mvc2Ctrl() {
		view = new Mvc2View();
		model = new Mvc2Model();
		handleEvents();
	}

	// 处理事件响应
	private void handleEvents() {
		addCloseLintener();
		addButtonListener();
		addButtonListener2();
	}

	// 窗体关闭事件相应
	private void addCloseLintener() {
		view.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.out.println("Exit MVC2");
				System.exit(0);
			}
		});
	}

	private void addButtonListener() {
		view.getButton().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				view.getLabel().setText(model.getText());
			}
		});
	}
	
	private void addButtonListener2() {
		view.getButton2().addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				view.getLabel2().setText(model.getText2());
			}
		});
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -