Chapter 16. An Example Ad-Hoc Component

This chapter describes an example of the design and implementation of an ad-hoc component with the Java programming language, focusing on the J2SE and the Swing library only.

Chapter 2 stated that a GUI can be thought of as being composed of visual components and their auxiliary elements. From a developer's viewpoint, such components can be thought of as belonging to three main groups, depending on their development cost:

  • Standard components, such as a 'plain' JTree instance.

  • Specialized components, such as a complex JTree subclass that re-implements many of the JTree auxiliary classes.

  • Ad-hoc components. These are visual components completely different than the standard ones provided by Swing or other GUI libraries. Ad-hoc components are much more expensive to develop, because their development effort comprises GUI design, testing, and coding.

If there were no reusable, standard libraries, we would develop components from scratch over and over, at enormous cost and without any coherence between different implementations of the same component. Luckily, the last twenty years of software engineering has provided today's developers with a wide range of tools for reusability and easy customization of their programs. See for example (McConnell 1993).

Unfortunately standard libraries don't cover all the possible components so that, although rarely, it is still possible to find yourself engaged in ad-hoc component building.

This chapter is structured as ...

Get Professional Java User Interfaces now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.