Beruflich Dokumente
Kultur Dokumente
Manifest-Version: 1.0
Name: com/class_dir/first.class
Java-Bean: true
Name: com/class_dir/second.class
Java-Bean: true
o cvfm
1
Create a new archive(c),
Produce verbose output when creating the jar(v)
Name of the jar file should be first file name that follows
the class files(f).
Given Manifest file for creating the jar file(m).
o Now a builder tool can add bean in the application.
o Builder tools also contain a property editor tool and event
descriptor, by which we can specify our values and events for a
beans to customize it.
• All event class must end in Event, and classes must extend the
EventObject class.
2
value is retrieved.
Bound Properties:Any change in bound property involves
some kind of action. Like a text field is bound
to a resultset value and any change in resultset
will lead to a change in text field value.
To implement this type of properties, the bean must send a
PropertyChange event to all register listeners.
The class PropertyChangeSupport manages to add or remove
any interested listener of the bean.
private PropertyChangeSupport changeSupport
= new PropertyChangeSupport(this);
To register the interested listener, bean has to implement
following two methods:
3
public void removeVetoableChangeListener
(VetoableChangeListener listener);
BeanInfo Classes:
• In a complex bean description, it may include set/ get method for other
purposes or bean couldn’t follow the standard naming convention.
• An object which implements BeanInfo interface can be used to
describe the naming pattern for a particular bean for use by a builder.
• The class name must suffix with ‘BeanInfo’.
• You can also extend SimpleBeanInfo convenience class to avoid
writing all the methods of BeanInfo interface.
4
Writing a Property Editor:
• One property editor is required for each property
• Property editor must implement the PropertyEditor interface
containing 12 methods.
• We can use PropertyEditorSupport class that is supplied with the
standard library.
• Builder follow this procedure to display the properties:
o It instantiate property editor for each property of the bean.
o It asks the bean to tell it the current value of the property.
o It then asks the property editor to display the value.
• The values can be displayed in either GUI based or text based.
Simple Property Editor:
• We use some mnemonics to define the property value, for eg. Text
size can be defined in one of the five choices as 1 to 5 digits.
• Now your code will return a wrapper class to return the selected value.
GUI based Property Editor:
• When the user clicks on the property editor, a pop up box comes, this
contains the sample text/ images for the selected values.
• The dialog box contains a component to edit the property value.
• To build a GUI based editor:
o Tell the builder tool that you will paint the value and not use a
string.
o “Paint” the value the user enters onto the GUI.
o Tell the builder tool that you will be using GUI-based property
editor.
o Build the GUI.
o Write the code to validate when the user tries to enter as the
value.
Customizers:
• It is better to supply one property editor for multiple property instead
of supplying multiple GUI based property editor for each property.
• To write customizer class , you must implement a Customizer
interface which has three methods:
o setObject method, which takes a parameter that specifies the
bean being customized.
o addPropertyChangeListener and
removePropertyChangeListener methods to notify the changes.