To create a JavaBean or a custom version of a user interface element that will
run with your WebForms application, you must supply a view class, that is, a
Java class that implements the IView
interface and that supports
the properties and listeners specific to that kind of view.
The supplied VBean
class extends the IView
interface.
Therefore, if you are creating a JavaBean container that extends VBean
,
you automatically obtain the IView
interface.
A class that implements IView
must have a constructor that takes
no arguments.
public interface IView { public void init (IHandler handler); public void destroy (); public Object getProperty(ID id); public boolean setProperty (ID id, Object value); public void addListener (Class type, EventListener listener); public void removeListener (Class type, EventListener listener); public void paint (Graphics g); public void repaint (Rectangle r); public void add (Object child, int index); public void remove (Object child); public void removeAll (); public boolean contains (int x, int y); }
public void init (IHandler handler)
The handler calls this method immediately after the WebForms applet constructs the object. The method passes the view object a reference to its handler and gives it a chance to perform initialization.
public void destroy ()
The WebForms applet calls this method to eliminate the object. The method releases any system resources that the object holds.
public Object getProperty (ID id)
This method returns the value of the requested property (identified by id
).
The view object must support the properties appropriate to its type (see below).
If this object does not support the specified property, the method returns null.
public boolean setProperty (ID id, Object value)
This method sets the value of the requested property (identified by id
)
to the value in Object value
. The view object must support the
properties appropriate to its type (see Properties
and Listeners Needed for User Interface Component Classes). If this object
does not support the specified property, the method returns false
.
Otherwise, it returns true
.
public void addListener (Class type, EventListener listener)
This method adds a listener of the specified name and type to the view object. The view object must support the listeners appropriate to its type (see Properties and Listeners Needed for User Interface Component Classes).
public void removeListener (Class type, EventListener listener)
This method removes the specified listener from the view object.
public void paint (Graphics g)
The handler calls this method to paint the view object, using the specified AWT Graphics object.
public void repaint (Rectangle r)
This method invalidates and repaints the specified rectangle. If the rectangle is null, the method invalidates and repaints the entire object.
public void add (Object child, int index)
This method adds the specified child to this object. It is added at the position
specified by the index
. To add the child
at the end
of the index, specify an index of -1.
public void remove (Object child)
This method removes the specified child from this object.
public void removeAll ()
This method removes all of this object’s children.
public boolean contains (int x, int y)
This method returns a value of true
if the specified point (x
,
y
) is in the selection region of the component. Otherwise, it returns
a value of false
.
How to Add JavaBeans by Writing Your Own Java Code