Chapter 4. Creating a view

 

This chapter covers

  • A brief introduction to Swing
  • The basics of a Griffon view
  • Composing views with legacy source code

Views in Griffon are responsible for composing the visuals aspects of your application. Views are what the user interacts with. There are hundreds of components that you can use to create a view; and no matter which one you choose, you can compose the view in the same manner via a specialized DSL based on Groovy’s SwingBuilder.

Griffon views can also be composed of other views, resulting not just in clever reuse of code but also in a way to display new elements on the fly.

In this chapter, we’ll take a deeper look at Griffon views. We’ll start by examining a classic Swing example and then compare it to a Griffon example that implements the same functionality. After you’ve see how much easier Griffon is, we’ll look at special features of Griffon views and how you can use these features to keep your code organized when you build a large application. We’ll end this chapter by showing how you can integrate views built with NetBeans GUI builder (formerly Matisse) and Abeille Forms Designer into a Griffon application.

We’re about to enter the wild yet amazing world that is Java Swing, If you’re not familiar with Swing, we encourage you to see Swing, 2nd edition (Manning, 2003) for a thorough primer. This chapter assumes you have a fair understanding of Swing.

4.1. Java Swing for the impatient

4.2. Groovy SwingBuilder: streamlined Swing

4.3. Anatomy of a Griffon view

4.4. Using special nodes

4.5. Managing large views

4.6. Using screen designers and visual editors

4.7. Summary