用于Java GUI应用程序的MVC / MVP / MVVM框架 [英] MVC/MVP/MVVM frameworks for Java GUI applications

查看:605
本文介绍了用于Java GUI应用程序的MVC / MVP / MVVM框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以推荐一个(最好是开源的)框架,用于在Java桌面应用程序中将GUI与模型分离吗?

Can anybody recommend a (preferably open-source) framework for decoupling GUI from model in Java desktop applications?

推荐答案

从根本上说最好使用数据绑定库将GUI模型与核心Java代码分离。也就是说你有你的pojo业务代码,你有GUI组件代码,并且你不想写一大堆逻辑来同时更新它们同时更新视图和实现业务逻辑。所以不要。找到您正在使用的GUI小部件的成熟数据绑定框架并了解它;让屏幕控件与你的pojo代码保持同步。

Fundamentally decoupling a GUI model from your core java code is best done with a databinding library. Which is to say you have your pojo business code, you have the GUI component code, and you don't fancy writing a load of logic to sync them up all the time whilst updating the view and implementing the business logic. So don't. Find a mature databinding framework for the GUI widgets you are using and learn that; have it keep the screen controls in sync with your pojo code.

JGoodies beanbindings 是绑定到OO模型的Swing变体的很好的例子。 JGoodies的核心部分是开源。如果你去jgoodies网站上的文章,它有关于模式和数据绑定的文章。虽然每个绑定框架具有不同的类,但是用于编写良好清洁代码的模式在GUI框架和绑定框架之间是可移植的。

JGoodies and beanbindings are good examples of Swing variants of binding onto an OO model. The core bits of JGoodies are opensource. If you go to /articles on the jgoodies site it has articles on pattern and databinding. Whilst each binding framework has different classes the patterns for writing good clean code are portable between GUI frameworks and bindings frameworks.

如果你下载了现在开源的 WindowsBuilderPro 工具,那么它在Swing和SWT中都有很好的例子来做好数据绑定。 swing jphonebook示例使用beanbindings库。 WindowsBuilderPro是一个拖放式GUI构建器;您曾经不得不支付它作为领先的拖放GUI构建器,它与领先的免费GUI库一起使用。它是由google和opensourced购买的,因此他们可以加强对GWT(Google Web GUI框架)的图形屏幕构建器支持。

If you download the now opensource WindowsBuilderPro tool then it has excellent examples in both Swing and SWT of doing good databindings. The swing jphonebook example uses the beanbindings library. WindowsBuilderPro is a drag and drop GUI builder; you used to have to pay for it as a leading drag and drop GUI builder which works with the leading free GUI libraries. It was bought by google and opensourced so that they could beef up its graphical screen builder support for GWT (the Google web GUI framework).

GUI构建器工具既有优秀的示例代码,又是一个优秀的开源工具。它在Swing和SWT GUI库中执行相同的电话簿示例,以演示其拖放式GUI构建器工具的功能。因此,在学习数据绑定的同时,将Swing与SWT进行比较和对比是一种很好的方法。

That GUI builder tool has both excellent sample code and is an excellent opensource tool now. It does the same example of a phonebook in both Swing and SWT GUI libraries to demo its drag-and-drop GUI builder tool power. So it is a great way to compare and contrast Swing to SWT whilst learning databindings.

这篇关于用于Java GUI应用程序的MVC / MVP / MVVM框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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