com.ibm.as400.ui.framework.java
Class HelpViewer

java.lang.Object
  |
  +--com.ibm.as400.ui.framework.java.HelpViewer

public class HelpViewer
extends java.lang.Object

Displays HTML-based help information in a JavaHelp window. For more information about JavaHelp, go to the Sun site.

HelpViewer correctly displays any HTML 3.2 content. It will hyperlink directly to a file in the same JAR file given a relative address, or it can hyperlink to any page on the web given a complete URL. The linked-to page must have content compatible with HTML 3.2, and can not contain JavaScript of Java applets as JavaHelp doesn't support them.

If your site uses a firewall, the java environment must be set to use a proxy (see below).

HelpViewer can be initialized with the URL of an html file, or the name of an HTML file in the classpath. If a name is specified, the HTML file, as well as the directory or JAR file will be determined. The JAR file will be used as a base for further relative links.

Sample code to set a proxy enabling URL's beyond a firewall:

 Properties systemProperties = System.getProperties();
 systemProperties.put("http.proxySet", "true");
 systemProperties.put("http.proxyHost", "proxy.myco.com"); // insert your proxy inet here 
 systemProperties.put("http.proxyPort", "81");
 System.setProperties(systemProperties);
 


Field Summary
static javax.help.HelpBroker OpNavHelpBroker
           
 
Constructor Summary
HelpViewer()
          Constructs a help viewer when help will be shown with a user-specified table of contents, index, and search.
HelpViewer(java.lang.String strFile)
          Constructs a help viewer.
HelpViewer(java.net.URL u)
          Constructs a help viewer.
HelpViewer(java.net.URL u, java.awt.Window w)
          Constructs a help viewer when help will be shown from a modal window.
 
Method Summary
static void clearCache()
           
protected  void finalize()
           
 java.lang.String getHome()
          Retrieves the current "home" setting, which is where the Help Topics button goes when pressed.
 java.lang.String getJarFileName()
          Gets the filename of the JAR file that contains the HelpSet.
static void main(java.lang.String[] args)
          Provides a command line interface to HelpViewer.
static void setActivationWindow(java.awt.Window w)
          Static method to set the owning modal window of the JavaHelp viewer.
 void setHome(java.lang.String home)
          Sets the current "home" setting, which is where the Help Topics button goes when pressed.
 void setHome(java.net.URL u)
          Sets the current "home" setting, which is where the Help Topics button goes when pressed.
 void setIconImage(java.awt.Image img)
           
 void setJarFileName(java.lang.String s)
          Sets the filename of the JAR file that contains the HelpSet.
 void setParentWindow(java.awt.Window w)
          Sets the owning modal window of the JavaHelp viewer.
 void setTitle(java.lang.String s)
          Sets the title of the JavaHelp viewer.
 void showHome()
          Causes the HTML display window to retrieve and display a page.
 void showHTML(java.lang.String HTMLText, java.lang.String anchor)
          Causes JavaHelp to display the passed String.
 void showPage(java.lang.String strFile)
          Causes JavaHelp to retrieve and display a page.
 void showPage(java.lang.String ID, java.lang.String HS)
          Causes JavaHelp to display the HTML file mapped to the passed ID (defined in the JavaHelp map file).
 void showPage(java.net.URL uResource)
          Causes JavaHelp to retrieve and show the passed-in URL.
 void showPage(java.net.URL u, java.lang.String HS)
          Causes JavaHelp to display the URL.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OpNavHelpBroker

public static javax.help.HelpBroker OpNavHelpBroker
Constructor Detail

HelpViewer

public HelpViewer()
Constructs a help viewer when help will be shown with a user-specified table of contents, index, and search.

Only use this constructor when you are displaying help in a user-specified HelpSet file. For example:

 HelpViewer hv = new HelpViewer();
 hv.showPage("myID",  "file:///g:/myhtml/myHS.hs");
 
The ID is the ID of HTML file to be displayed (defined in the JavaHelp map file), and the HelpSet is the JavaHelp HelpSet.

HelpViewer

public HelpViewer(java.net.URL u)
Constructs a help viewer. A URL input is assumed to be a help resource. The .html extension may be left off, it will be automatically added, along with locale information when the classpath is searched.
Parameters:
u - the URL to display

HelpViewer

public HelpViewer(java.lang.String strFile)
Constructs a help viewer. A string input is assumed to be a help resource. A search is made of the classpath to find the resource. The .html extension may be left off, it will be automatically added, along with locale information when the classpath is searched.

The following displays myHTML.html when it is in a JAR file in the classpath or when the root directory is in the classpath:

 HelpViewer hv = new HelpViewer("myhtml/myHTML.hmtl");
 hv.showPage("myhtml/myHTML.hmtl");
 
You can also fully qualify the path to the file, such as "file:///c:/myhtml/myHTML.html".
Parameters:
strFile - the file Name

HelpViewer

public HelpViewer(java.net.URL u,
                  java.awt.Window w)
Constructs a help viewer when help will be shown from a modal window. A URL input is assumed to be a help resource. The .html extension may be left off, it will be automatically added, along with locale information when the classpath is searched.
Parameters:
u - the URL to display
w - the parent window
Method Detail

main

public static void main(java.lang.String[] args)
Provides a command line interface to HelpViewer. Allows preview of HTML documents, including those within a JAR file. Searches for the HTML document within the classpath.
 java com.ibm.as400.ui.framework.java.HelpViewer <resource URL> | <document name>
 
or
 java com.ibm.as400.ui.framework.java.HelpViewer <ID> <HelpSet>     
 

The HTML document must be specified as one of the following:

<resource URL>
The fully qualified URL of the HTML document.

Example: java com.ibm.as400.ui.framework.java.HelpViewer "file:///c:/myhtml/mypage.html"

<document name>
The fully qualified document name. Directories and JARs in the classpath will be searched.

Example: java com.ibm.as400.ui.framework.java.HelpViewer "mypage.html"

Example: java com.ibm.as400.ui.framework.java.HelpViewer "com/myco/mypackage/mypage.html"

<ID>
ID of the HTML file to be displayed (defined in the JavaHelp map file).
<HelpSet>
The JavaHelp HelpSet file associated with this help topic.
Parameters:
args - the arguements passed to main().
Since:
v4r2m0

showPage

public void showPage(java.lang.String strFile)
Causes JavaHelp to retrieve and display a page. If the input is a complete URL, it will be retrieved and shown. If only a file name, the input will be found in the JAR file, or in a directory in the classpath and shown.
Parameters:
strFile - the page to be displayed.

showPage

public void showPage(java.net.URL uResource)
Causes JavaHelp to retrieve and show the passed-in URL.
Parameters:
URL - the URL to be displayed.

showPage

public void showPage(java.lang.String ID,
                     java.lang.String HS)
Causes JavaHelp to display the HTML file mapped to the passed ID (defined in the JavaHelp map file). The map file is called out in the HelpSet file. Construct a HelpViewer using the default constructor before using this method. For example:
 HelpViewer hv = new HelpViewer();
 hv.showPage(myID,  file:///g:/myhtml/myHS.hs)   
 
Parameters:
ID - the ID of HTML file to be displayed (defined in the JavaHelp map file).
HS - the JavaHelp HelpSet that calls out the JavaHelp map file.

showPage

public void showPage(java.net.URL u,
                     java.lang.String HS)
Causes JavaHelp to display the URL. Construct a HelpViewer using the default constructor before using this method. For example:
 HelpViewer hv = new HelpViewer();
 hv.showPage(URL,  file:///g:/myhtml/myHS.hs)   
 
Parameters:
u - the URL of the HTML file to be displayed.
HS - the JavaHelp HelpSet to use when displaying the URL.

showHTML

public void showHTML(java.lang.String HTMLText,
                     java.lang.String anchor)
Causes JavaHelp to display the passed String. The String should contain HTML formatting. If an internal anchor is passed, JavaHelp navigates to it.

Warning: This method will not work in applet mode.

Parameters:
HTMLText - the text to be displayed.
anchor - the anchor to navigate to.

getHome

public java.lang.String getHome()
Retrieves the current "home" setting, which is where the Help Topics button goes when pressed.
Returns:
the home URL

setHome

public void setHome(java.net.URL u)
Sets the current "home" setting, which is where the Help Topics button goes when pressed.
Parameters:
u - the home URL

setHome

public void setHome(java.lang.String home)
Sets the current "home" setting, which is where the Help Topics button goes when pressed.
Parameters:
home - the home URL

showHome

public void showHome()
Causes the HTML display window to retrieve and display a page. If the input is a complete URL, it will be retrieved and shown. If only a File name, the input will be found in the jar file, or in a directory in the CLASSPATH and shown.

setIconImage

public void setIconImage(java.awt.Image img)

setParentWindow

public void setParentWindow(java.awt.Window w)
Sets the owning modal window of the JavaHelp viewer.
Parameters:
w - the owning modal window.

setActivationWindow

public static void setActivationWindow(java.awt.Window w)
Static method to set the owning modal window of the JavaHelp viewer.
Parameters:
w - the owning modal window.

setTitle

public void setTitle(java.lang.String s)
Sets the title of the JavaHelp viewer.
Parameters:
s - the title.

setJarFileName

public void setJarFileName(java.lang.String s)
Sets the filename of the JAR file that contains the HelpSet.
Parameters:
s - the filname of the JAR.

getJarFileName

public java.lang.String getJarFileName()
Gets the filename of the JAR file that contains the HelpSet.

clearCache

public static void clearCache()

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object