Wednesday, 5 February 2014

Event classes:The ContainerEvent Class

 ContainerEvent:added to or removed from a container.

The ContainerEvent Class


A ContainerEvent is generated when a component is added to or removed from a container.


 container events:


  •  COMPONENT_ADDED 
  •  COMPONENT_REMOVED

They indicate that a component has been added to or removed from the container.
ContainerEvent is a subclass of ComponentEvent and has this constructor:



ContainerEvent  Constructor:


ContainerEvent(Component src, int type, Component comp)

Here,src is a reference to the container that generated this event. The type of the event is specified bytype, and the component that has been added to or removed from the container is comp.


Method in ContainerEvent class


getContainer( ) method:

            You can obtain a reference to the container that generated this event by using the getContainer() method, shown here:

Container getContainer( )

getChild( ) method:

              The getChild( ) method returns a reference to the component that was added to or removed from the container. Its general form is shown here:

Component getChild( )

No comments:

Post a Comment