Java 2中的MVC设计模式

王朝java/jsp·作者佚名  2008-05-31
窄屏简体版  字體: |||超大  

一个好的用户界面(GUI)的设计通常可以在现实世界找到相应的表现。

例如,假如在您的面前摆放着一个类似于电脑键盘按键的一个简单的按钮,然而就是这么简单的一个按钮,我们就可以看出一个GUI设计的规则,它由两个主要的部分构成,一部分使得它具有了按钮应该具有的动作特性,例如可以被按下。另外一部分则负责它的表现,例如这个按钮是代表了A还是B。

//[C] 2002 Sun Microsystems, Inc.---

import Java.awt.BorderLayout;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import java.util.ArrayList;

import java.util.Iterator;

import javax.swing.BoxLayout;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JScrollPane;

import javax.swing.JTextArea;

import javax.swing.JTextField;

public class RunMVCPattern {

public static void main(String [] arguments){

System.out.println("Example for the MVC pattern");

System.out.println();

System.out.println("In this example, a Contact is divided into");

System.out.println(" Model, View and Controller components.");

System.out.println();

System.out.println("To illustrate the flexibility of MVC, the same");

System.out.println(" Model will be used to provide information");

System.out.println(" to two View components.");

System.out.println();

System.out.println("One view, ContactEditView, will provide a Contact");

System.out.println(" editor window and will be paired with a controller");

System.out.println(" called ContactEditController.");

System.out.println();

System.out.println("The other view, ContactDisplayView, will provide a");

System.out.println(" display window which will reflect the changes made");

System.out.println(" in the editor window. This view does not support");

System.out.println(" user interaction, and so does not provide a controller.");

System.out.println();

System.out.println("Creating ContactModel");

ContactModel model = new ContactModel();

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航