## Merging Helpsets Dynamically

In addition to the static merging of helpsets described in Merging Helpsets, helpsets can be merged dynamically. To merge helpsets dynamically, you use the JavaHelp software API in your Java applications.

The basic API consists of the `HelpSet.add(HelpSet)` method and its corresponding `HelpSet.remove(HelpSet)`method. These methods fire `HelpSetEvent` events for the `HelpSetListeners` that have registered interest in them. The Component UIs for the TOC, index, search, and glossary views register for these events and react to changes.

The semantics of merging is implemented by individual `NavigatorView` objects and `JHelpNavigator` objects. There are three basic methods:

- `canMerge(NavigatorView)`
- `merge(NavigatorView)`
- `remove(NavigatorView)`

The `canMerge(NavigatorView)` method is present in both `NavigatorView` and `JHelpNavigator`. The `JHelpNavigator` method just calls into its corresponding `NavigatorView` method. The other two methods are present only in `JHelpNavigator`.

For more information about these classes and methods, refer to the JavaHelp software API documentation. API information can be viewed using a web browser (`doc/api/overview-summary.html`) or by using the sample API viewer in `demos\bin\apiviewer`.

Two demonstration programs, `demos\bin\merge` and `demos\bin\newmerge` are included with the JavaHelp system release. These programs demonstrate how helpsets can be merged and removed dynamically. The `newmerge` program demonstrates what happens with a UniteAppendMerge of TOCs and a SortMerge of indexes.

The sources for these programs are available under `demos\src\sunw\demo\`.