components have been added to the frame.
3. (Optional) For any component who's name does not match its help topic id code the following:
>>>> helpContext.addHelpComponent( component, "topicId" );
4. (Optional) Supply a TextComponent to display the tool descriptions:
>>>> helpContext.setToolDescriptionDisplay( yourTextComponent );
The following is some example code which sets up context sensitive help:
public void addNotify() {
// Call parents addNotify method.
super.addNotify();
// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
//{{INIT_CONTROLS
setLayout(null);
setVisible(false);
...
showContentsButton = new java.awt.Button();
showContentsButton.setLabel("Show Contents");
showContentsButton.setBounds(insets().left + 216,insets().top + 108,96,24);
add(showContentsButton);
display = new java.awt.TextField();
display.setBounds(insets().left + 180,insets().top + 36,168,36);
add(display);
...
//}}
// Give the components a name that the help system recoginizes.
showButton.setName("TopicId_ShowContents");
// Create the HelpDeskContext. It will scan through and default a topic for each component.
helpContext = new HelpContextImpl( this, helpSystem, "YourContextId" );
// Since the component "display" name doesn't match its topic id re-add it to the HelpContext.
helpContext.addComponentHelp( display, "TopidId_Display" );
// Supply a TextComponent which will be used to display the tool descriptions.
helpContext.setToolDescriptionDisplay( statusField );
// Show help contents when showContens button is pressed.
showContentsButton.addActionListener(
// Anonymous inner class
new java.awt.event.ActionListener() {
public void actionPerformed( java.awt.event.ActionEvent event ) {
helpContext.showContents();
}
}
);
} // addNotify()
Supported API: true
Extendable: false
HELP_SYSTEM
public static final String HELP_SYSTEM
- Tag for the helpSystem property.
- See Also:
- Constant Field Values
CONTEXT_ID
public static final String CONTEXT_ID
- Tag for the contextId attribute.
- See Also:
- Constant Field Values
CONTAINER
public static final String CONTAINER
- Tag for the context container.
- See Also:
- Constant Field Values
TOOL_DESCRIPTION
public static final String TOOL_DESCRIPTION
- Tag for the toolDescription attribute.
- See Also:
- Constant Field Values
TOOL_TIP_TEXT
public static final String TOOL_TIP_TEXT
- Tag for the toolTipText attribute.
- See Also:
- Constant Field Values
getHelpSystem
public HelpSystem getHelpSystem()
- Getter for the helpSystem property.
- Returns:
- the help system for this context.
setHelpSystem
public void setHelpSystem(HelpSystem newValue)
throws PropertyVetoException
- Setter for the help desk property.
- Parameters:
newValue
- the new help desk.
- Throws:
PropertyVetoException
- if the new value is invalid.
getContextId
public String getContextId()
- Getter for the contextId attribute.
- Returns:
- the id for this context, may be null.
setContextId
public void setContextId(String newValue)
throws PropertyVetoException
- Setter for the contextId.
- Parameters:
newValue
- the new value of the context id.
- Throws:
PropertyVetoException
- if the new value is invalid.
getContainer
public Container getContainer()
- Getter for the context container.
- Returns:
- the container instance, may be null.
setContainer
public void setContainer(Container newValue)
throws PropertyVetoException
- Setter for the context container.
- Parameters:
newValue
- the new container.
- Throws:
PropertyVetoException
- if the new value is invalid.
initialize
public void initialize()
throws PropertyVetoException
- Initialize the help context. This operation requires that the helpSystem,
contextId, and the container have been set.
Operation initialize causes this HelpContext to start listening to the container
and its components. The topic id for each component defaults to the components
name. This means that the components name should match the topic id. To override
a component topic id use operation addComponentHelp.
- Throws:
PropertyVetoException
- thrown if the above properties are not set.
getToolDescription
public String getToolDescription()
- Getter for the toolDescription attribute. This returns the tool
description for the component over which the mouse resides.
- Returns:
- the current tool description, may be null.
getToolTipText
public String getToolTipText()
- Getter for the toolTipText attribute. This returns the current tool tip text.
- Returns:
- tool tip text, may be null.
setToolDescriptionDisplay
public void setToolDescriptionDisplay(TextComponent textComponent)
- Operation settoolDescriptionDisplay is a convensiance operation which allows the client
to specify a TextComponent which is used to display the tool description for the component
which is under the mouse. This is a conveniance because this function could be achieved using
the addPropertyChangeListener and listening for PropertyChangeEvents which have property name
TOOL_DESCRIPTION.
- Parameters:
textComponent
- the TextComponent which will display tool descriptions, may be null.
showContents
public void showContents()
- Show help contents for this context.
addComponentHelp
public void addComponentHelp(Component component,
String topicId)
- Associate a component with a help system topicId.
- Parameters:
component
- the component for help.topicId
- the help system topic id.
removeComponentHelp
public void removeComponentHelp(Component component)
- Remove the component from the help system.
- Parameters:
component
- the component to remove help.
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
- Add a property change listener which may listen for changes to properties
and attributes specified above.
- Parameters:
listener
- the listener.
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
- Remove the listener from the list of property change listeners.
- Parameters:
listener
- the listener to remove.
stopIt
public void stopIt()
- Stop context help and release resources.