IComponent Interface

IComponent Interface

This Package | All Packages

public interface IComponent

The IComponent interface represents a component. To be a component, a class must implement IComponent. Components can be hosted in containers. For each component in a container, the container creates a site that acts as a binding link between the component and the container.

Methods
Name Description
addOnDispose(EventHandler value) Adds an OnDispose event handler.
dispose() Disposes a component.
getChildOf(IComponent component) Checks if this component is a child of the specified component.
getSite() Returns the site of this component.
removeOnDispose(EventHandler value) Removes an OnDispose event handler.
setSite(ISite value) Sets the site of this component.

Methods

IComponent.addOnDispose

Syntax
public void addOnDispose( EventHandler value );
Description

Adds an OnDispose event handler. The OnDispose event is fired when the component's dispose() method is called. Components that maintain references to other components can register OnDispose event handlers for the referenced components so that the references can be cleared when the components are disposed.

IComponent.dispose

Syntax
public void dispose();
Description

Disposes a component. A call to dispose() indicates that the user of the component has no further need for the component. An implementation of dispose() must:

  1. Remove any references the component is holding to other components. This is typically accomplished by assigning null to any fields that contain references to other components.
  2. Release any system resources that are associated with the component, such as file handles, window handles, or database connections.
  3. Dispose any child components, such as child windows or submenu items, by calling the dispose() method of those components. The isChildOf() method of the components that are disposed in this fashion must return true when passed this component.
  4. Remove the component from its container. If the component has a site, it must execute "site.getContainer().removeComponent(this)", where "site" is the current (non-null) site.
  5. Fire an OnDispose event to any event handlers that have been registered through the addOnDispose() method.

Ideally, a call to dispose() will revert a component to the state it was in immediately after it was created. This is, however, not a requirement. Following a call to dispose(), a component is permitted to raise exceptions for operations that cannot meaningfully be performed.

IComponent.getChildOf

Syntax
public boolean getChildOf( IComponent component );
Description

Checks if this component is a child of the specified component. A component is considered a child of a specified parent component if the parent component's implementation of the dispose() method also disposes the child component. Examples of child components are child windows and submenus.

IComponent.getSite

Syntax
public ISite getSite();
Description

Returns the site of this component. The value returned must be the value that was passed to the most recent call to setSite(), or null if no calls have been made to setSite().

IComponent.removeOnDispose

Syntax
public void removeOnDispose( EventHandler value );
Description

Removes an OnDispose event handler.

IComponent.setSite

Syntax
public void setSite( ISite value );
Description

Sets the site of this component. A non-null value indicates that the component has been added to a container; a null value indicates that the component is being removed from a container. An implementation of setSite() is required to store the specified value and return the same value from subsequent calls to getSite().