Adding Context Sensitive Help
General Remark
Context Sensitive Help displays a certain help topic
for a component that has either focus or is selected with
the mouse. It is quite easy to implement it. See also the
API documentation for JavaHelp.
Direct Help 
Direct Help is a feature that lets you display help
for a component that is selected with the mouse. Usually
the cursor for the mouse changes for that task. It is
often connected with a special help menuitem. To do this,
you have to:
-
Set a helpID for the component you want to provide
with help. The helpID should be a valid target in
your
Map.jhm file. Here we assume that
getMyPanel() returns a
Component .
javax.help.CSH.setHelpIDString(getMyPanel(), "html.mypanel");
-
Create a button or menu item with the special action
listener of the following code example. This listener takes
care of changing the cursor, tracking your mouse
click and finally displaying the target you set for
the selected component in the previous step. If there
is no special target for the selected component, the
default (TOP) target will be displayed.
helpItem.addActionListener(new CSH.DisplayHelpAfterTracking(mainHelpBroker));
Help from Focus
This displays help for the component that has
currently the focus. You may create a button on that
component to enable it. The procedure is similar to the
one described in the above section, except that there is
another listener CSH.DisplayHelpFromFocus
instead of CSH.DisplayHelpAfterTracking.
-
Create a helpID for the component you want to provide
with help.
javax.help.CSH.setHelpIDString(getMyPanel(), "html.mypanel");
-
Create a button or menu item with a special action
listener.
helpItem.addActionListener(new CSH.DisplayHelpFromFocus(mainHelpBroker));
This examples assumes, that you have already created a
HelpBroker.
See also: Adding a Help Menu
Item
|