Chapter 15. JavaBeans

   

Java™ 2 Primer Plus
By Steven Haines, Steve Potts

Table of Contents
Part III:  Graphical User Interfaces


You will learn about the following in this chapter:

  • What makes a class a JavaBean

  • How to develop a Simple JavaBean

  • How to deploy JavaBeans in Forte

  • How to add custom methods to your Bean

  • How to define a bound property

For software developers, software components are the equivalent to Ponce de Leon's Fountain of Youth. If software can be componentized like silicon chips, developers can drag and drop them into their applications thereby saving time and money.

In Java 1.01, there was no easy way to add components to the AWT Toolkit. The reason this was so hard was the existence of the operating system peer component. This peer component had to be one of the widgets or controls that was native to the operating system. When a Java GUI object was created, the JVM would create the native GUI object and place it on the Frame or Panel. This peer was unique to every platform, preventing the programmer from implementing a "write once, run anywhere" component.

When Sun introduced the Swing library as a download in Java 1.1, it provided not only a set of new components, but also an entire architecture the JavaBean Architecture for implementing components. In fact, the Swing library is composed entirely of JavaBeans.

Enormous amounts of time and energy have been spent in the past few years trying to devise schemes so that a developer can assemble an application from components. Developing an architecture to support widespread code reuse has proven elusive, but a lot of good software has resulted from the effort.

One of these successes has been the JavaBean architecture. This architecture has proved useful in producing software rapidly in certain cases. These cases tend to be in the area of creating Graphical User Interfaces (GUI).

JavaBeans are Java's version of the ActiveX controls (formerly known as Visual Basic Extensions (VBXs), and later OLE Control Extensions (OCXs). These controls, introduced around 1990, found a valuable niche in hiding the complexity of the Windows operating system from the programmers. VBXs could be used to build graphical interfaces using Visual Basic or included in source code using Visual C++. One senior developer was heard saying, "The day that Visual Basic was released, the high school student next door became a better Windows programmer than me!"

Beyond just hiding the Windows API from programmers (and it did need hiding), Visual Basic showed that far more programming could be done using drag and-drop components than previously thought possible. It created a new category of development products now known as Rapid Application Development (RAD) tools. Although RAD products still require quite a bit of hand coding, they speed up the development of a certain category of application-GUI front ends that access and modify database tables. Attempts to go beyond these applications into game development, communications, and distributed object programming have met with mixed results.

JavaBeans are the Java version of VBX/OCX/ActiveX. They are pieces of code that are often represented visually as icons in an Integrated Development Environment (IDE). They may or may not have a visual representation at runtime.

In this chapter, you will learn how to create JavaBeans, add custom events, and test and deploy them in a commercial product.


       
    Top
     



    Java 2 Primer Plus
    Java 2 Primer Plus
    ISBN: 0672324156
    EAN: 2147483647
    Year: 2001
    Pages: 332

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net