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

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

问题描述

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

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.

JGoodiesbeanbindings 都不错绑定到 OO 模型的 Swing 变体示例.JGoodies 的核心部分是开源的.如果您访问 jgoodies 站点上的/articles,它会提供有关模式和数据绑定的文章.虽然每个绑定框架都有不同的类,但是编写好的干净代码的模式在 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 构建器付费,它可以与领先的免费 G​​UI 库配合使用.它被谷歌收购并开源,以便他们可以加强对 GWT(谷歌 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天全站免登陆