带有swing实现Java的MVC [英] MVC with swing implementation java

查看:79
本文介绍了带有swing实现Java的MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑MVC如何与GUI Swing应用程序一起工作.我使用过PHP MVC,但是完全不同.我了解MVC代表什么.但是令我感到困惑的是在GUI swing编程中所做的不同变化.很难从Web上的不同文章中得出特定的结论.谁应该知道谁?我的意思是模型视图和控制器之间的关系是什么?控制器应该同时知道模型和视图吗?我想举一个简单的例子来说明这一点(就像一个简单的按钮,它将更新标签)

I am confused how MVC will work with GUI swing application. I have worked with PHP MVC but that is totally different. I understand what MVC stands for. But what making me confused is different variation of doing it in GUI swing programming. It is hard to conclude particular thing from different articles in web. Who should know whom? I mean what will be the relation between model view and controller? Should controller know both model and the view? I would like to an simple example if possible to illustrate this (like and simple button which will update a label)

如果我不提出更多要求,我希望获得有关MVC书籍的建议,因为它是摇摆不定的.

If i am not asking more i would like to get sugetions of MVC book which is writtern Swing in mind.

推荐答案

如果您问10个不同的人"MVC是什么意思?" ,您可能会得到10个不同的答案.我个人很喜欢MVC的这种定义(至少对于非Web应用程序而言):

If you ask 10 different people "What does MVC mean?" you'll probably get 10 different answers. I'm personally partial to this definition of MVC (at least for non-web apps):

模型-视图-控制器设计模式

基本上,控制器提供的唯一功能是在应用程序启动时实例化模型和视图并将它们彼此连接.其他一切只是将程序的数据和逻辑(模型)与您选择向用户显示并允许用户交互(视图)的方式适当地分离.

Basically, the only functions the controller serves is to instantiate model and the view as the application starts up and connect them to one another. Everything else is just proper decoupling of your program's data and logic (model) from how you choose to display it to the user and allow user interaction (view).

这篇关于带有swing实现Java的MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆