All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jHelp.htmlHelpPanel

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----jHelp.htmlHelpPanel

public class htmlHelpPanel
extends Panel
implements ActionListener, AdjustmentListener, htmlLinkListener
A class to provide a help browser component, consisting of a scrolling text canvas, and a vertical scrollbar. The scrollbar may optionally be removed.

The htmlHelpPanel constructors require the instance of the parent container as the first argument. This is used by jHelp to determine if the class is being invoked by an applet or application. Standalone applications invoking applet classes that deploy jHelp must supply the application Frame to jHelp's constructor, and not the applet instance.

All constructors take a fileName argument, a String comprised of one or more help source file names. Where more than one help file is being loaded in the constructor, the names should be entered as a single string, with the file names delimited by a '|' character.

For example

      new htmlHelpPanel(this,"help1.html|help2.html|help3.html")
 

Help files need not be loaded during construction, and can be added using the addFile method. However, this is not necessary, as new files will be loaded automatically on demand if not already loaded.

The first file named in the fileNames argument will be the default file displayed in the browser panel.

You can instantiate an htmlHelpPanel with null as the fileNames argument, which creates a blank display.

You can also instantiate an htmlHelpPanel with a zip or jar file, which should contain the help documents that will be used.


Variable Index

 o actionListener
 o DYN_NAME
 o DYN_PREFIX
 o DYNAMIC

Constructor Index

 o htmlHelpPanel(Object, String)
The basic htmlHelpPanel constructor is provided for use as a browser widget.
 o htmlHelpPanel(Object, String, int)
This constructor permits specifying the width of the scrollbar without passing navigation buttons.
 o htmlHelpPanel(Object, String, int, Locale)
This constructor permits specifying the width of the scrollbar without passing navigation buttons.
 o htmlHelpPanel(Object, String, Locale)
The basic htmlHelpPanel constructor is provided for use as a browser widget.
 o htmlHelpPanel(Object, String, Object, Object)
This htmlHelpPanel constructor is provided for developers to produce customized framed help browsers, basing their code on the htmlHelpFrame source code, if available.
 o htmlHelpPanel(Object, String, Object, Object, int)
This htmlHelpPanel constructor permits specifying the width of the vertical scrollbar along with back and forward buttons.
 o htmlHelpPanel(Object, String, Object, Object, int, Locale)
This htmlHelpPanel constructor permits specifying the width of the vertical scrollbar along with back and forward buttons.
 o htmlHelpPanel(Object, String, Object, Object, Locale)
This htmlHelpPanel constructor is provided for developers to produce customized framed help browsers, basing their code on the htmlHelpFrame source code, if available.

Method Index

 o actionPerformed(ActionEvent)
 o addActionListener(ActionListener)
 o addFile(Object, String)
The addFile method permits loading additional help source files subsequent to construction.
 o addHTMLString(Object, String, String)
The addHTMLString method permits loading dynamically generated HTML content.
 o adjustmentValueChanged(AdjustmentEvent)
 o enableStacks(Object, Object)
Normally, if forward/back navigation buttons are provided, they are specified in the constructor.
 o getCurrentFileName()
Returns the name of the current document.
 o getInsets()
 o getMaxCache()
This method returns the current number of documents that will be retained in memory.
 o goBack()
This method causes the help panel to retrieve the previous document or location (after a hypertext jump) if any.
 o goForward()
This method causes the help panel to retrieve the next document or location (after a hypertext jump) if any.
 o goTo(String)
This method permits setting the panel explicitly to a helpfile and optionally, a location within the help file.
 o goTo(String, int)
This method permits setting the panel explicitly to a helpfile and optionally, a location within the help file with an element index.
 o handleDefaultLink(htmlLinkEvent)
The default internal link handler

 o handleLink(htmlLinkEvent)
The internal link handler that may be overridden to provide customized link handling.
 o moreDown()
This method returns true if the current document may still be scrolled up.
 o moreUp()
This method returns true if the current document may still be scrolled down.
 o noScrollbar()
This method is used to remove the scrollbar.
 o pageDown()
This method is used to scroll down one page increment.
 o pageUp()
This method is used to scroll up one page increment.
 o paint(Graphics)
 o printHelpFile(Frame)
Invokes printing the current document.
 o removeActionListener(ActionListener)
 o resetStacks()
This method can be called to force clearing/resetting the back/forward navigation stacks.
 o setGoToBase(String)
This method permits setting a help document path at runtime, so that the goTo method can be used with a filename, rather than an explicit path when it needs to be invoked.
 o setJhelpListener(htmlJhelpListener)
Sets an external listener, implementing htmlJhelpListener, that may respond to the user hiding the htmlHelpFrame, or a low memory or other exception, thrown when jHelp attempts to create the text image.
 o setMaxCache(int)
This method permits setting a maximum number of help documents that are retained in memory by jHelp.
 o setText(String)
A convenience method to display a String of text.
 o update(Graphics)

Variables

 o DYN_PREFIX
 public static final String DYN_PREFIX
 o DYN_NAME
 public static final String DYN_NAME
 o DYNAMIC
 public static final String DYNAMIC
 o actionListener
 protected ActionListener actionListener

Constructors

 o htmlHelpPanel
 public htmlHelpPanel(Object instance,
                      String fileNames)
The basic htmlHelpPanel constructor is provided for use as a browser widget. It creates a scrolling canvas to display text, and a scrollbar.

It need not be explicitly instantiated when the htmlHelpFrame is used.

Parameters:
instance - the parent instance, should either be an applet or application Frame
fileNames - a String of one or several help source files, separated by '|', a null, or the name of a zip or jar file.
See Also:
addFile
 o htmlHelpPanel
 public htmlHelpPanel(Object instance,
                      String fileNames,
                      Object backButton,
                      Object forwardButton)
This htmlHelpPanel constructor is provided for developers to produce customized framed help browsers, basing their code on the htmlHelpFrame source code, if available.

The backButton and forwardButton arguments are declared as Components to provide for flexibility in passing custom widgets, such as image buttons.

Parameters:
instance - the parent instance, should either be an applet or application Frame
fileNames - a String of one or several help source files, separated by '|', a null, or the name of a zip or jar file.
backButton - the component or widget to act as a 'back button'
forwardButton - the component or widget to act as a 'forward button'
See Also:
addFile
 o htmlHelpPanel
 public htmlHelpPanel(Object instance,
                      String fileNames,
                      Object backButton,
                      Object forwardButton,
                      int scrollwidth)
This htmlHelpPanel constructor permits specifying the width of the vertical scrollbar along with back and forward buttons.

Parameters:
instance - the parent instance, should either be an applet or application Frame
fileNames - a String of one or several help source files, separated by '|', a null, or the name of a zip or jar file.
backButton - the component or widget to act as a 'back button'
forwardButton - the component or widget to act as a 'forward button'
scrollwidth - the width of the scrollbar
See Also:
addFile
 o htmlHelpPanel
 public htmlHelpPanel(Object instance,
                      String fileNames,
                      int scrollwidth)
This constructor permits specifying the width of the scrollbar without passing navigation buttons.

Parameters:
instance - the parent instance, should either be an applet or application Frame
fileNames - a String of one or several help source files, separated by '|', a null, or the name of a zip or jar file.
scrollwidth - the width of the scrollbar
See Also:
addFile
 o htmlHelpPanel
 public htmlHelpPanel(Object instance,
                      String fileNames,
                      Locale locale)
The basic htmlHelpPanel constructor is provided for use as a browser widget. It creates a scrolling canvas to display text, and a scrollbar. Normally, jHelp uses the users default locale when obtaining jHelp's resources. This constructor lets you specify a specific Locale object.

It need not be explicitly instantiated when the htmlHelpFrame is used.

Parameters:
instance - the parent instance, should either be an applet or application Frame
fileNames - a String of one or several help source files, separated by '|', a null, or the name of a zip or jar file.
locale - a Locale object that jHelp will attempt to use in ResourceBundle.getBundle
See Also:
addFile
 o htmlHelpPanel
 public htmlHelpPanel(Object instance,
                      String fileNames,
                      Object backButton,
                      Object forwardButton,
                      Locale locale)
This htmlHelpPanel constructor is provided for developers to produce customized framed help browsers, basing their code on the htmlHelpFrame source code, if available.

The backButton and forwardButton arguments are declared as Components to provide for flexibility in passing custom widgets, such as image buttons.

This constructor also permits passing a Locale object, to override jHelp's default behavior of getting the default Locale on the users machine.

Parameters:
instance - the parent instance, should either be an applet or application Frame
fileNames - a String of one or several help source files, separated by '|', a null, or the name of a zip or jar file.
backButton - the component or widget to act as a 'back button'
forwardButton - the component or widget to act as a 'forward button'
locale - a Locale object that jHelp will attempt to use in ResourceBundle.getBundle
See Also:
addFile
 o htmlHelpPanel
 public htmlHelpPanel(Object instance,
                      String fileNames,
                      Object backButton,
                      Object forwardButton,
                      int scrollwidth,
                      Locale locale)
This htmlHelpPanel constructor permits specifying the width of the vertical scrollbar along with back and forward buttons.

This constructor also permits passing a Locale object, to override jHelp's default behavior of getting the default Locale on the users machine.

Parameters:
instance - the parent instance, should either be an applet or application Frame
fileNames - a String of one or several help source files, separated by '|', a null, or the name of a zip or jar file.
backButton - the component or widget to act as a 'back button'
forwardButton - the component or widget to act as a 'forward button'
scrollwidth - the width of the scrollbar
locale - a Locale object that jHelp will attempt to use in ResourceBundle.getBundle
See Also:
addFile
 o htmlHelpPanel
 public htmlHelpPanel(Object instance,
                      String fileNames,
                      int scrollwidth,
                      Locale locale)
This constructor permits specifying the width of the scrollbar without passing navigation buttons.

This constructor also permits passing a Locale object, to override jHelp's default behavior of getting the default Locale on the users machine.

Parameters:
instance - the parent instance, should either be an applet or application Frame
fileNames - a String of one or several help source files, separated by '|', a null, or the name of a zip or jar file.
scrollwidth - the width of the scrollbar
locale - a Locale object that jHelp will attempt to use in ResourceBundle.getBundle
See Also:
addFile

Methods

 o noScrollbar
 public void noScrollbar()
This method is used to remove the scrollbar. It should be called prior to placing the htmlHelpPanel component in your Container's layout.

 o pageUp
 public void pageUp()
This method is used to scroll up one page increment. It is equivalent to the same action generated by clicking on the scrollbar, and is provided for htmlHelpPanels that remove the scrollbar.

 o moreUp
 public boolean moreUp()
This method returns true if the current document may still be scrolled down.

 o pageDown
 public void pageDown()
This method is used to scroll down one page increment. It is equivalent to the same action generated by clicking on the scrollbar, and is provided for htmlHelpPanels that remove the scrollbar.

 o moreDown
 public boolean moreDown()
This method returns true if the current document may still be scrolled up.

 o getCurrentFileName
 public String getCurrentFileName()
Returns the name of the current document.

 o getInsets
 public final Insets getInsets()
Overrides:
getInsets in class Container
 o paint
 public final void paint(Graphics g)
Overrides:
paint in class Container
 o update
 public final void update(Graphics g)
Overrides:
update in class Component
 o addFile
 public void addFile(Object instance,
                     String fileName)
The addFile method permits loading additional help source files subsequent to construction. However, unlike the constructor, only a single file can be specified.This method need not be used in practice, although it continues to be supported. Calling htmlHelpPanel.goTo(filename) will automatically load the requested file if it is not in the document cache.

Note that adding a file does not place its contents in the display. It simply loads the document into jHelp's document cache. You must still use htmlHelpPanel.goTo(filename) to display the file.

Similar to this class's constructors, addFile requires the instance of the parent container as the first argument. This is used by jHelp to determine if the class is being invoked by an applet or application. Standalone applications invoking applet classes that deploy jHelp must supply the application Frame to this constructor, and not the applet instance.

The fileName argument is a String comprised of a single help source file.

Parameters:
instance - the parent instance, should either be an applet or application Frame
fileName - a String consisting of the name of one help source file.
 o addHTMLString
 public void addHTMLString(Object instance,
                           String content,
                           String name)
The addHTMLString method permits loading dynamically generated HTML content. This method requires the String object containing the HTML to be displayed and a name to be given to the object for referencing with the show() method. If a name is not required (i.e. no external reference to this content will be made) pass null as the name. In this case, future content can be added which will replace the current content for dynamic HTML.

Note well that if you reference any external objects, such as images or links to actual help files, you must define a <BASE HREF=...> if the referenced objects are not within the current working directory of your application.

Parameters:
instance - the parent instance, should either be an applet or application Frame
content - a String consisting of the HTML code to be displayed
name - a String consisting of the name to be assigned the dynamic HTML object with null passed as a name for disposable content.
 o addActionListener
 public void addActionListener(ActionListener l)
 o removeActionListener
 public void removeActionListener(ActionListener l)
 o actionPerformed
 public void actionPerformed(ActionEvent e)
 o adjustmentValueChanged
 public void adjustmentValueChanged(AdjustmentEvent e)
 o goBack
 public void goBack()
This method causes the help panel to retrieve the previous document or location (after a hypertext jump) if any.

 o goForward
 public void goForward()
This method causes the help panel to retrieve the next document or location (after a hypertext jump) if any.

 o goTo
 public void goTo(String context)
This method permits setting the panel explicitly to a helpfile and optionally, a location within the help file. The context argument takes the same form as an HREF, such as help1.html#Usage, or simply #Usage. The latter form will attempt to find the bookmark in the currently active help file.

If a context requests a file that has not been loaded, either in the constructor, or with the addFile method, then jHelp will attempt to load the requested help file.

Parameters:
context - the hyperlink to a file and/or bookmark
 o goTo
 public void goTo(String filename,
                  int index)
This method permits setting the panel explicitly to a helpfile and optionally, a location within the help file with an element index. It is primarily intended to be used by htmlHelpIndexFrame. The filename is assumed to be relative to the current "goToBase" path setting.

Parameters:
filename - the name of the requested file
index - the index number of the element to seek for the top of the display
 o setGoToBase
 public void setGoToBase(String path)
This method permits setting a help document path at runtime, so that the goTo method can be used with a filename, rather than an explicit path when it needs to be invoked. Note, that if this is used, then all subsequent goTo(filenames) will prepend the specified base path to the named file. To clear this base, call this method with null as the path argument.

If you have specified a zip or jar as the source of help files in the constructor then this method is used to specify the path of help files within the zip.

This base can also be overridden by specifying a help document as an absolute URL, prefixed with either file:// or http://

Parameters:
path - the directory (local or URL) where referenced help documents are located
 o printHelpFile
 public void printHelpFile(Frame frame)
Invokes printing the current document.

Parameters:
frame - the Frame object that is passed to java.awt.Toolkit.getPrintJob
 o setMaxCache
 public void setMaxCache(int value)
This method permits setting a maximum number of help documents that are retained in memory by jHelp. Useful for programs that deploy large sets of help documents to prevent jHelp from exhausting resources if many documents are browsed. A value of zero will cause jHelp to retain all documents in its memory cache (the default.)

Parameters:
value - a positive integer representing the number of documents that may be retained.
 o getMaxCache
 public int getMaxCache()
This method returns the current number of documents that will be retained in memory. A value of zero indicates that all documents will be retained in the memory cache.

 o setText
 public void setText(String text)
A convenience method to display a String of text. Equivalent to
 addHTMLString(instance, text, null);
 

Parameters:
text - the text to display
 o handleDefaultLink
 public final void handleDefaultLink(htmlLinkEvent e)
The default internal link handler

Parameters:
e - the htmlLinkEvent passed to this handler
 o handleLink
 public void handleLink(htmlLinkEvent e)
The internal link handler that may be overridden to provide customized link handling. This method simply calls and passes the event to the default link handler.

Parameters:
e - the htmlLinkEvent passed to this handler
 o resetStacks
 public void resetStacks()
This method can be called to force clearing/resetting the back/forward navigation stacks. This will automatically disable the back/forward button components as the stacks are emptied.

 o enableStacks
 public void enableStacks(Object backButton,
                          Object forwardButton)
Normally, if forward/back navigation buttons are provided, they are specified in the constructor. This method permits setting navigation controls after construction to enable the navigation stacks.

The arguments may be standard AWT components, or custom components. They may also be null objects. However, in order to function automatically, non-component objects should implement htmlNavControl so that jHelp's navigational stack manager can enable/disable as appropriate.

Parameters:
backButton - the object that will serve as a "back" control
forwardButton - the object that will serve as a "forward" control
 o setJhelpListener
 public void setJhelpListener(htmlJhelpListener l)
Sets an external listener, implementing htmlJhelpListener, that may respond to the user hiding the htmlHelpFrame, or a low memory or other exception, thrown when jHelp attempts to create the text image.

Parameters:
l - an object implementing htmlJhelpListener

All Packages  Class Hierarchy  This Package  Previous  Next  Index