Skip to main content.

Web Based Programming Tutorials

Homepage | Forum - Join the forum to discuss anything related to programming! | Programming Resources

Presenting JavaBeans

Presenting JavaBeans


About the Author


Michael Morrison is a technical writer, software developer, and avid skateboarder living in Nashville, Tennessee with his immortal beloved, Mahsheed. Michael is a contributing author to Teach Yourself Java in 21 Days, Professional Reference Edition and Late Night Visual J++, as well as the lead author of Java Unleashed, Second Edition. If you're ever in the Nashville area, there's a good chance you can catch Michael skateboarding at XXX Sports. Otherwise, you can reach him via e-mail at mmorrison@thetribe.com, or on the Web at http://www.thetribe.com.

Tell Us What You Think!

As a reader, you are the most important critic and commentator of our books. We value your opinion and want to know what we're doing right, what we could do better, what areas you'd like to see us publish in, and any other words of wisdom you're willing to pass our way. You can help us make strong books that meet your needs and give you the computer guidance you require.

Do you have access to CompuServe or the World Wide Web? Then check out our CompuServe forum by typing GO SAMS at any prompt. If you prefer the World Wide Web, check out our site at http://www.mcp.com.


NOTE: If you have a technical question about this book, call the technical support line at 800-571-5840, ext. 3668.

As the publishing manager of the group that created this book, I welcome your comments. You can fax, e-mail, or write me directly to let me know what you did or didn't like about this book--as well as what we can do to make our books stronger. Here's the information:

Fax: 317-581-4669

E-mail: newtech_mgr@sams.mcp.com

Mail: Mark Taber
Sams.net Publishing
201 W. 103rd Street
Indianapolis, IN 46290

Introduction


With Java fast on its way to becoming the standard programming language and runtime environment of choice for the Internet, many have wondered what's next for Java. JavaSoft, the makers of Java, apparently had similar thoughts after the incredible success of Java. JavaSoft realized that Java clearly had lots of potential in terms of the Internet, but it also started realizing that its benefits extended far beyond online applications. Instead of standing around waiting to see what other people could do with Java, JavaSoft seized the opportunity to assess the weaknesses of Java and beef it up with new technologies in order to make it a well-rounded software technology. One of these new Java-related technologies is JavaBeans, which is Java's answer to component software.

If you aren't familiar with component software, it is a type of software that is designed heavily around the idea of code reuse and compartmentalization. Component software is a very popular and powerful concept that is rapidly being used throughout the software industry to increase development efficiency. Software components are designed and built so that they can be accessed and used in a variety of different development and runtime scenarios. The JavaBeans component software technology is based on Java and provides a means of creating and using Java classes as software components. JavaBeans is very significant to the future of Java because many viewed the lack of a component software technology as a big weakness in Java.

JavaSoft saw the need as well and quickly made JavaBeans a high priority on its list. When assessing the initial goals of JavaBeans, the architects at JavaSoft managed to come up with a very simple mission statement that cuts right to the point of what the JavaBeans technology is to accomplish. This mission statement follows:

"Write once, run anywhere, reuse everywhere."

This statement expresses the goals of JavaBeans in a very simple, concise, and elegant set of requirements. The first of these requirements, "write once," refers to the need for JavaBeans code to be written once and not require rewrites to add or improve functionality. The second requirement, "run anywhere," refers to the need for JavaBeans components to be able to run on a wide range of operating system platforms. The final requirement, "reuse everywhere," refers to the need for JavaBeans components to be reusable in a variety of different applications and in different types of development environments.

Although the requirements of the JavaBeans mission statement are admittedly a little vague, they nevertheless paint a general picture of what the technology is to accomplish. This book is devoted to exploring the JavaBeans technology and shedding light on how this mission statement is met throughout the various parts of JavaBeans. Throughout this book you learn all about JavaBeans at a conceptual level by addressing each fundamental area of the technology. You also learn a great deal about JavaBeans from a very practical perspective by building your own JavaBeans components that can be reused in your own Java applets or applications.

Even though the main premise of this book is to introduce you to the JavaBeans technology, I think you'll be pleasantly surprised by the depth in which JavaBeans is covered. Even so, I make every effort to keep you on a level footing by balancing technical details with practical concepts. When all is said and done, I think you'll agree that JavaBeans is quite possibly the most exciting technology to come about since Java itself. I had a lot of fun working with JavaBeans during the development of this book, and I truly look forward to putting it to work in my own projects.

Who Should Read This Book?

This book covers the JavaBeans technology from a few different angles. As such, the book targets a variety of different readers with different technical backgrounds and expertise. From a conceptual perspective, this book requires little more than a basic understanding of the Java programming language and runtime system. However, Part III, "Creating Your Own Beans," delves into JavaBeans component creation and requires a definite knowledge of Java programming. If you are a Java programmer, you will find yourself right at home with this book, particularly Part III. On the other hand, if you are interested only in learning about the conceptual aspects of the JavaBeans technology, you will still find a great deal of the book useful and insightful.

Regardless of your technical knowledge or reason for wanting to learn about JavaBeans, keep in mind that at least a general knowledge of Java is required to fully appreciate the coverage of JavaBeans. This is due to the fact that JavaBeans is itself an extension of the Java technology. I encourage you to refer to one of the many books that cover the Java programming language and runtime system if you have no prior knowledge of Java.

How This Book Is Organized

This book is divided into four parts and four appendixes, each of which takes a different approach to exploring the JavaBeans technology. Although there is naturally some overlap of material between each part of the book, the goal of each of them is to examine JavaBeans from a different perspective. Although these parts aren't entirely sequential, there is definitely a benefit to reading them in order.

In Part I, "Introduction to JavaBeans," you learn the basics about software components and why they are so important to the future of software development. You then learn about the fundamentals of JavaBeans, as well as the JavaBeans API.

In Part II, "Inside the JavaBeans API," you move into the specifics of the JavaBeans API. Each chapter in this part of the book focuses on a fundamental section of the JavaBeans API. These fundamental API sections correspond to major functional areas of JavaBeans, and consist of properties, introspection, events, persistence, and customization.

In Part III, "Creating Your Own Beans," you move from the conceptual to the practical by learning how to build your own beans. You begin by learning the basics behind general bean construction. From there, you spend the remaining chapters developing your own beans. These beans include a fancy button bean, a meter bar bean, an LED display bean, and an audio player bean.