Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC/MVP/MVVM frameworks for Java GUI applications

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

like image 891
Alexey Romanov Avatar asked Jun 04 '10 19:06

Alexey Romanov


2 Answers

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 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.

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).

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.

like image 80
simbo1905 Avatar answered Nov 14 '22 21:11

simbo1905


Java Swing actually makes good use of MVC for just this purpose.

like image 21
Justin Ethier Avatar answered Nov 14 '22 22:11

Justin Ethier