Geertjan is a DZone Zone Leader and has posted 459 posts at DZone. You can read more from them at their website. View Full User Profile

Porting to Griffon

09.15.2008
| 28555 views |
  • submit to reddit

In Flying with Griffon, I created a simple scenario in Griffon, to show how this new Swing MVC framework functions and what some of its benefits are. A different approach, one that is potentially even more illustrative, is to take an existing Java desktop application and port it to Griffon. That is what I propose to do in this article.

First, a puzzler. What's the difference between these two screenshots?

Answer: The 1st is one of the standard Java desktop samples delivered with every distribution of NetBeans IDE. It is a small GUI application, with a JFrame designed in the Matisse GUI Builder, with an interface and an implementation for evaluating the user's attempt at figuring out anagrams. And what's the 2nd screenshot? It's the same application, this time written on the Griffon framework! Clearly the result is identical, at least at face value. You're going to have to trust me that the rest works the same too or simply follow the instructions below and see for yourself.

Before looking at the advantages and disadvantages of porting an application to Griffon, let's look at what it mean to "port an application to Griffon". Below you see a screenshot of both applications. The first is the original Java application, i.e., the same as you'll find in NetBeans IDE, while the second is the Griffon equivalent:

Look at the first application and then look at the second. Some of the advantages of the second should be obvious already. But before exploring these, let's take the MVC approach to examining each of the parts you see above and what it took to port them:

By the way, thanks a lot to Andres Almiray, who looked at the code in this sample and tweaked quite a lot of it. He's not responsible for any remaining inaccuracies, however!

AttachmentSize
fig-1.png11.5 KB
fig-2.png11.43 KB
fig-3.png58.63 KB
fig-4.png11.42 KB
Published at DZone with permission of its author, Geertjan Wielenga.