Professional Documents
Culture Documents
Java Beans
Java Beans
• The basic format of the command for viewing the contents of a JAR
file is: jar tf jar-file Let's look at the options and argument used in
this command:
• The t option indicates that you want to view the table of contents of
the JAR file.
• The f option indicates that the JAR file whose contents are to be
viewed is specified on the command line.
• The jar-file argument is the path and name of the JAR file whose
contents you want to view.
• The t and f options can appear in either order, but there must not be
any space between them.
• This command will display the JAR file's table of contents to stdout.
• You can optionally add the verbose option, v, to produce additional
information about file sizes and last-modified dates in the output.
• Creating a simple bean
• Compiling the bean
• Generating a Java Archive (JAR) file
• Loading the bean into the GUI Builder of
the NetBeans IDE
• Inspecting the bean's properties and
events
Advantages of Java Beans
• A Bean obtains all the benefits of Java's "write-once, run-anywhere" paradigm.
• The properties, events, and methods of a Bean that are exposed to an application
builder tool can be controlled.
• Auxiliary software can be provided to help a person configure a Bean. This software is only
needed when the design-time parameters for that component are being set. It
does not need to be included in the run-time environment.
• The configuration settings of a Bean can be saved in persistent storage and restored
at a later time.
• A Bean may register to receive events from other objects and can generate events that are
sent to other objects.
Introspection
• This is the process of analyzing a bean to
determine its capabilities.
• Simple properties
• Indexed properties
Using the Bean Info Interface
• Property Descriptor[ ] getPropertyDescriptors()
• EventSetDescriptor[ ] getEventSetDescriptors()
• MethodDescriptor[ ] getMethodDescriptors()
• These are defined with java.beans package and they describe the indicated
elements.By implementing these methods a developer can designate
exactly what is presented to a user bypassing introspection based on design
patterns.
• When creating a class that implements BeanInfo class name should
ClassNameBeanInfo.
• It provide default implementation of all three methods.
• import java.awt.*;
• import java.beans.*;
• }
• Bound and Constrained properties:Must Implement a
PropertyChangeListner interface.
• Customizers
• JavaBeans API