Preface

The first time I heard about JavaBeans was at JavaOne '96. I was very impressed, but I thought it would take a few years to actually implement JavaBeans. I was excited when Sun released the first version of JavaBeans specifications in October of 1996. Sun developed this spec with the help of other vendors, especially Borland. Despite some omissions, the JavaBeans specification was a very good document and had a number of basic things clearly spelled out. Sun later released the Beans Develpment Kit (BDK) for developing JavaBeans. The BDK with its excellent bean testing tool, the BeanBox, has evolved into an extremely useful and reliable JavaBeans development tool.

Right after the BDK release, I started writing a number of real-word beans for a variety of applications using the BDK. As I gained more experience, my beans got better and better. The book is a culmination of that experience.

My original intention was to write a concise book and at the same time make it complete with respect to JavaBeans. While the size of the book is a little larger than I originally intended, I think I have succeeded to a large extent in making the book complete with respect to JavaBeans. This book is very JavaBean focused. Except for a couple of topics, all the chapters directly deal with JavaBeans. While you need to know Java and many related topics to understand JavaBeans, covering them here would have made the book huge and, in my opinion, would have distracted the readers.

This book is primarily intended for programmers who want to build beans. This book covers, for the most part, the JavaBeans 1.0 and the related APIs in Java Developer's Kit (JDK) 1.1. The examples discussed in the part I and the beans in part II are all developed using JDK 1.1.

Java is still evolving and so is JavaBeans. At the time of this writing, the second generation JavaBeans specification code named Glasgow has been released and a part of it has been incorporated into JDK 1.2 beta 2. Also released recently is the Enterprise JavaBeans Specification which is targeted towards business applications. It is a major step in the evolution of JavaBeans.

What's in this book?

The first part of the book is about building Java Beans. In addition to providing an in-depth coverage of JavaBeans topics and related issues, it provides detailed steps to building beans. The second part provides a detailed description of some real-world beans. Some of them were written by me and some were contributed by others. Source code and class files for the beans are available from the Manning web site (

Part I

The first chapter, "Introduction," provides a general discussion on JavaBeans. It also tells you where to start learning about JavaBeans.

The second chapter, "JavaBeans model," provides a complete overview of JavaBeans. Some of the topics are a summary of JavaBeans specification. The chapter is quite intense and has lot of reference material. I expect you to come back to this chapter to refer to some topics.

The third chapter, "Creating and assembling simple beans," shows how to write and assemble simple beans through a sample application. This chapter provides details on both visual and manual assembly.

In the fourth chapter, "Building run-time classes," we step into the real world. This chapter addresses the some real-world bean design issues. It also provides runtime class implementation details. This includes implementing serialization and bound/constrained properties.

The fifth chapter, "Building design-time classes," describes how to develop designtime-only classes needed for providing information about a bean.

The sixth chapter, "Building property editors and customizers," shows how to build custom property editors and customizers.

The seventh chapter, "Packaging and delivery," describes the Java Archive (JAR) and shows how to package beans in a jar file.

The eighth chapter, "Applets and beans," discusses the applet basics and describes how to convert your bean to applets and vice versa.

The ninth chapter, "JavaBeans to ActiveX," was contributed by Robann Mateja and walks you through the steps required in converting a bean to an ActiveX control. This chapter shows how to run and connect the converted beans in a Visual Basic environment.

The tenth chapter, "ActiveX to JavaBeans," was contributed by Gopalan Raj and walks you through the process of creating a simple ActiveX control. This chapter goes on to show how to convert this ActiveX control into a bean using both the Taligent's Migration Assistant and Microsoft's JActiveX.

The eleventh chapter, "Building beans using tools," describes a couple of bean building and testing tools.

The twelfth chapter, "Advanced JavaBeans," is all about the next generation JavaBeans. It provides an overview of Glasgow specs and InfoBus.

Part II

Part II provides complete documentation of beans. The beans covered include Spreadsheet, Plotter beans, Image Loader, Image Visualization beans, File Printer, Java Database Connectivity (JDBC) and Jzoom. It has an interesting bean contributed by Rutgers University. This bean can be used for constructing simple, realtime, and collaborative applications.

Appendix

"Appendix A: A recipe to write your own beans" consolidates all the steps discussed in different chapters. This can be useful as a quick reference to bean developers.

"Appendix B: Using the reflection API" covers the reflection API from the JavaBeans standpoint.

"Appendix C: The beans API" provides an overview of beans API.

"Appendix D: Miscellaneous" covers inner classes and collections.