简体   繁体   English

用于Java GUI应用程序的MVC / MVP / MVVM框架

[英]MVC/MVP/MVVM frameworks for Java GUI applications

任何人都可以推荐一个(最好是开源的)框架,用于将GUI与Jav​​a桌面应用程序中的模型分离开来吗?

Fundamentally decoupling a GUI model from your core java code is best done with a databinding library. 从根本上将GUI模型与核心Java代码分离最好使用数据绑定库。 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. 也就是说,你有自己的pojo业务代码,你有GUI组件代码,并且你不想写一大堆逻辑来同时更新它们同时更新视图和实现业务逻辑。 So don't. 所以不要。 Find a mature databinding framework for the GUI widgets you are using and learn that; 找到您正在使用的GUI小部件的成熟数据绑定框架并了解它; have it keep the screen controls in sync with your pojo code. 让屏幕控件与你的pojo代码保持同步。

JGoodies and beanbindings are good examples of Swing variants of binding onto an OO model. JGoodiesbeanbindings是绑定到OO模型的Swing变体的很好的例子。 The core bits of JGoodies are opensource. JGoodies的核心部分是开源。 If you go to /articles on the jgoodies site it has articles on pattern and databinding. 如果你去jgoodies网站上的文章,它有关于模式和数据绑定的文章。 Whilst each binding framework has different classes the patterns for writing good clean code are portable between GUI frameworks and bindings frameworks. 虽然每个绑定框架具有不同的类,但是用于编写良好清洁代码的模式在GUI框架和绑定框架之间是可移植的。

If you download the now opensource WindowsBuilderPro tool then it has excellent examples in both Swing and SWT of doing good databindings. 如果你下载了现在开源的WindowsBuilderPro工具,那么它在Swing和SWT中都有很好的例子来做好数据绑定。 The swing jphonebook example uses the beanbindings library. swing jphonebook示例使用beanbindings库。 WindowsBuilderPro is a drag and drop GUI builder; WindowsBuilderPro是一个拖放GUI构建器; you used to have to pay for it as a leading drag and drop GUI builder which works with the leading free GUI libraries. 您曾经不得不支付它作为领先的拖放GUI构建器,它与领先的免费GUI库一起使用。 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). 它是由google和opensourced购买的,因此他们可以加强对GWT(Google Web GUI框架)的图形屏幕构建器支持。

That GUI builder tool has both excellent sample code and is an excellent opensource tool now. 该GUI构建器工具具有出色的示例代码,现在是一个出色的开源工具。 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. 它在Swing和SWT GUI库中执行相同的电话簿示例,以演示其拖放式GUI构建器工具的功能。 So it is a great way to compare and contrast Swing to SWT whilst learning databindings. 因此,在学习数据绑定的同时,将Swing与SWT进行比较和对比是一种很好的方法。

I would strongly suggest you to try the ZK framework. 我强烈建议你尝试ZK框架。 I have not found until today such a srtong framework. 直到今天我才发现这样一个srtong框架。 In my company we have applied new projects within a few weeks using the latest patterns like MVVM. 在我的公司,我们使用像MVVM这样的最新模式在几周内应用了新项目。 The style of programming is much like developing a classic 'desktop' app. 编程风格与开发经典的“桌面”应用程序非常相似。

PS: I am in no way related to the ZK people. PS:我与ZK人没有任何关系。 I am just using their framework. 我只是在使用他们的框架。

Java Swing实际上很好地利用了MVC来达到这个目的。

From your reaction to the suggestion that Swing is an MVC framework for desktop apps, I think that you really need some kind of generator framework that will generate the 'model' and 'view' code from higher level specifications. 从您对Swing是桌面应用的MVC框架的建议的反应来看,我认为您确实需要某种生成器框架来生成更高级别规范的“模型”和“视图”代码。 Examples I'm (more or less) familiar with are Eclipse EMF, GEF and related technologies. 我(或多或少)熟悉的示例是Eclipse EMF,GEF和相关技术。

Biscotti是一个很棒的框架

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM