⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 制作java应用程序的帮助文件.htm

📁 制作java应用程序的帮助文件
💻 HTM
📖 第 1 页 / 共 3 页
字号:
            Last<BR>目录建好了以后,我们要在Help目录下面写出四个文件:hello.hs,Map.jhm,index.xml以及toc.xml<BR>hello.hs:<BR>&lt;?xml 
            version='1.0' encoding='ISO-8859-1' ?&gt;<BR>&lt;!DOCTYPE 
            helpset<BR>PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet 
            Version 
            1.0//EN"<BR>"http://java.sun.com/products/javahelp/helpset_1_0.dtd"&gt;<BR><BR>&lt;helpset 
            version="1.0"&gt;<BR>&lt;title&gt;Hello, 
            JavaHelp&lt;/title&gt;<BR>&lt;maps&gt;<BR>&lt;mapref 
            location="Map.jhm"/&gt;<BR>&lt;homeID&gt;overview&lt;/homeID&gt;<BR>&lt;/maps&gt;<BR>&lt;view&gt;<BR>&lt;name&gt;TOC&lt;/name&gt;<BR>&lt;label&gt;TOC&lt;/label&gt;<BR>&lt;type&gt;javax.help.TOCView&lt;/type&gt;<BR>&lt;data&gt;toc.xml&lt;/data&gt;<BR>&lt;/view&gt;<BR>&lt;view&gt;<BR>&lt;name&gt;Index&lt;/name&gt;<BR>&lt;label&gt;Index&lt;/label&gt;<BR>&lt;type&gt;javax.help.IndexView&lt;/type&gt;<BR>&lt;data&gt;index.xml&lt;/data&gt;<BR>&lt;/view&gt;<BR>&lt;/helpset&gt;<BR>下面是Map.jhm文件的内容:<BR>&lt;?xml 
            version='1.0' encoding='ISO-8859-1' ?&gt;<BR>&lt;!DOCTYPE 
            map<BR>PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp Map Version 
            1.0//EN"<BR>"http://java.sun.com/products/javahelp/map_1_0.dtd"&gt;<BR><BR>&lt;map 
            version="1.0"&gt;<BR>&lt;mapID target="overview" 
            url="Hello/overview.htm" /&gt;<BR>&lt;mapID target="one" 
            url="Hello/First/one.htm" /&gt;<BR>&lt;mapID target="two" 
            url="Hello/First/two.htm" /&gt;<BR>&lt;mapID target="three" 
            url="Hello/Last/three.htm" /&gt;<BR>&lt;mapID target="four" 
            url="Hello/Last/four.htm" 
            /&gt;<BR>&lt;/map&gt;<BR>下面是index.xml文件的内容:<BR>&lt;?xml 
            version='1.0' encoding='ISO-8859-1' ?&gt;<BR>&lt;!DOCTYPE 
            index<BR>PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp Index 
            Version 
            1.0//EN"<BR>"http://java.sun.com/products/javahelp/index_1_0.dtd"&gt;<BR><BR>&lt;index 
            version="1.0"&gt;<BR>&lt;indexitem text="The 
            First?"&gt;<BR>&lt;indexitem target="one" text="I'm 
            One"/&gt;<BR>&lt;indexitem target="two" text="I'm 
            Second"/&gt;<BR>&lt;/indexitem&gt;<BR>&lt;indexitem text="The 
            Last?"&gt;<BR>&lt;indexitem target="three" text="We're 
            Third!"/&gt;<BR>&lt;indexitem target="four" text="We're 
            Last"/&gt;<BR>&lt;/indexitem&gt;<BR>&lt;indexitem target="overview" 
            text="Overview!!!"/&gt;<BR>&lt;/index&gt;<BR><BR>下面是toc.xml文件的内容:<BR>&lt;?xml 
            version='1.0' encoding='ISO-8859-1' ?&gt;<BR>&lt;!DOCTYPE 
            toc<BR>PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp TOC Version 
            1.0//EN"<BR>"http://java.sun.com/products/javahelp/toc_1_0.dtd"&gt;<BR><BR>&lt;toc 
            version="1.0"&gt;<BR>&lt;tocitem image="toplevelfolder" 
            target="overview" text="Hello, JavaHelp"&gt;<BR>&lt;tocitem 
            text="First Stuff"&gt;<BR>&lt;tocitem target="one" text="The 
            One"/&gt;<BR>&lt;tocitem target="two" text="The 
            Second"/&gt;<BR>&lt;/tocitem&gt;<BR>&lt;tocitem text="Last 
            Stuff"&gt;<BR>&lt;tocitem target="three" text="What's 
            Third?"/&gt;<BR>&lt;tocitem target="four" text="The 
            End"/&gt;<BR>&lt;/tocitem&gt;<BR>&lt;/tocitem&gt;<BR>&lt;/toc&gt;<BR>创建好以上四个文件以后,记得把它们放到help目录下面,<BR>现在需要四个htm文件,把帮助内容写在htm里面,<BR>Hello/overview.htm<BR>Hello/First/one.htm<BR>Hello/First/two.htm<BR>Hello/Last/three.htm<BR>Hello/Last/four.htm<BR>那么现在Help目录下的结构就变成了下面一样:<BR>+ 
            help<BR>hello.hs<BR>index.xml<BR>Map.jhm<BR>toc.xml<BR>+ 
            Hello<BR>overview.htm<BR>+ First<BR>one.htm<BR>two.htm<BR>+ 
            Last<BR>three.htm<BR>four.htm<BR>还记得开始让你下载的JavaHelp吗?解包以后在jh1.1.3\demos\bin目录下面有个hsviewer.jar文件<BR>我们用它来查看帮助文件是否做得完美,将hsviewer.jar加入到classpath里面<BR>假如jh1.1.3解压到了E:\,<BR>set 
            classpath=%classpath%;E:\jh1.1.3\demos\bin\hsviewer.jar<BR>然后执行:<BR>java 
            sunw.demo.jhdemo.JHLauncher<BR>有一个图形界面出来,按浏览按钮找到Help\hello.hs文件,按display显示帮助文件。<BR></FONT><FONT 
            face=arial,sans-serif color=#000000 size=2>helpset显示如下图:<BR><IMG 
            alt="" hspace=0 src="" align=baseline border=0></FONT></P>
            <P><FONT face=arial,sans-serif color=#000000 
            size=2><BR><BR><STRONG><FONT 
            color=#ff0033><BR>2,将帮助加到你的应用中来。</FONT></STRONG><BR>本质上,将应用程序和HelpSet联系起来的方法就是<BR>将帮助文件名映射到swing的组件里来。这时你需要jh.jar<BR>这个文件在jh1.1.3\javahelp\lib里面,你必须把它加入classpath<BR>或者是拷贝到jre\lib\ext目录下。如果你用JBuilder,可以在菜单<BR>Tools的Configure 
            Libraries里面增加一个Lib,选择jh.jar,然后在<BR>Project里面选择使用这个Lib。<BR>javahelp的lib不小,其实核心的三个类HelpSet, 
            HelpBroker,和CSH<BR>就可以使javahelp运行起来了。<BR>首先导入javahelp的类:<BR>import 
            javax.help.*;<BR>然后你得找到HelpSet文件,通过包含HelpSet的URL对象<BR>或者使用HelpSet类的findHelpSet方法得到URL对象,<BR>findHelpSet方法通过ClassLoader找到帮助文件。<BR>有了URL对象以后就可以构造一个HelpSet对象了:<BR>import 
            java.net.*;<BR>...<BR><BR>HelpSet helpset = null;<BR>ClassLoader 
            loader = null;<BR>URL url = HelpSet.findHelpSet(loader, 
            "hello.hs");<BR>try {<BR>helpset = new HelpSet(loader, url);<BR>} 
            catch (HelpSetException e) {<BR>System.err.println("Error 
            loading");<BR>return;<BR>}<BR>然后你要从helpset得到HelpBroker对象 
            。<BR>HelpBroker helpbroker = 
            helpset.createHelpBroker();<BR><BR>最后是帮助跟组件的绑定。<BR>ActionListener 
            listener = <BR>new 
            CSH.DisplayHelpFromSource(helpbroker);<BR>overview.addActionListener(listener);<BR><BR><BR><BR>完整代码如下:<BR>import 
            javax.swing.*;<BR>import java.awt.*;<BR>import 
            java.awt.event.*;<BR>import javax.help.*;<BR>import 
            java.net.*;<BR><BR>public class HelloHelp {<BR>public static void 
            main(String args[]) {<BR>JFrame frame = new JFrame("Hello, 
            JavaHelp");<BR>frame.setDefaultCloseOperation(<BR>JFrame.EXIT_ON_CLOSE);<BR>Container 
            content = frame.getContentPane();<BR><BR>JMenuBar menubar = new 
            JMenuBar();<BR>JMenu helpMenu = new JMenu("Help");<BR>JMenuItem 
            overview = new JMenuItem("Overview");<BR>JMenuItem specific = new 
            JMenuItem("Specific");<BR>helpMenu.add(overview);<BR>helpMenu.add(specific);<BR>menubar.add(helpMenu);<BR>frame.setJMenuBar(menubar);<BR><BR>JButton 
            button1 = new JButton("The Button");<BR>JButton button2 = new 
            JButton("Context");<BR><BR>content.add(button1, 
            BorderLayout.NORTH);<BR>content.add(button2, 
            BorderLayout.SOUTH);<BR><BR>HelpSet helpset = null;<BR>ClassLoader 
            loader = null;<BR>URL url = HelpSet.findHelpSet(loader, "hello.hs"); 
            <BR>try {<BR>helpset = new HelpSet(loader, url);<BR>} catch 
            (HelpSetException e) {<BR>System.err.println("Error 
            loading");<BR>return;<BR>}<BR><BR>HelpBroker helpbroker = 
            helpset.createHelpBroker();<BR><BR>ActionListener listener = <BR>new 
            CSH.DisplayHelpFromSource(helpbroker);<BR>overview.addActionListener(listener);<BR><BR>CSH.setHelpIDString(specific, 
            "one");<BR>specific.addActionListener(listener);<BR><BR>CSH.setHelpIDString(button1, 
            "two");<BR>ActionListener tracker = <BR>new 
            CSH.DisplayHelpAfterTracking(helpbroker);<BR>button2.addActionListener(tracker);<BR><BR>JRootPane 
            rootpane = 
            frame.getRootPane();<BR>helpbroker.enableHelpKey(rootpane, "three", 
            helpset);<BR><BR>frame.setSize(200, 
            200);<BR>frame.show();<BR>}<BR>}</FONT></P>
            <P><FONT face=arial,sans-serif color=#000000 
            size=2>以上目录和文件以及程序你可以在http://www.jzventures.com/javahelp.zip下载。<BR></P></FONT></SPAN><BR>
            <DIV 
            style="FONT-SIZE: 14px; LINE-HEIGHT: 25px"><STRONG>作者Blog:</STRONG><A 
            id=ArticleContent1_ArticleContent1_AuthorBlogLink 
            href="http://blog.csdn.net/gdsean/" 
            target=_blank>http://blog.csdn.net/gdsean/</A></DIV>
            <DIV 
            style="FONT-SIZE: 14px; COLOR: #900; LINE-HEIGHT: 25px"><STRONG>相关文章</STRONG></DIV>
            <TABLE id=ArticleContent1_ArticleContent1_RelatedArticles 
            style="BORDER-COLLAPSE: collapse" cellSpacing=0 border=0>
              <TBODY>
              <TR>
                <TD><A 
                  href="http://dev.csdn.net/article/14/article/24/24895.shtm">为自己的系统搞个全文搜索</A> 
                </TD></TR>
              <TR>
                <TD><A 
                  href="http://dev.csdn.net/article/14/article/23/23784.shtm">写自己的rss</A> 
                </TD></TR>
              <TR>
                <TD><A 
                  href="http://dev.csdn.net/article/14/article/23/23776.shtm">为jive论坛加上投票功能</A> 
                </TD></TR>
              <TR>
                <TD><A 
                  href="http://dev.csdn.net/article/14/article/23/23774.shtm">为jive论坛加上投票功能</A> 
                </TD></TR>
              <TR>
                <TD><A 
                  href="http://dev.csdn.net/article/14/article/22/22505.shtm">缓存JSP显示的html</A> 
                </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><A name=#Comment></A>
      <TABLE cellPadding=0 width="100%" border=0>
        <TBODY>
        <TR>
          <TD>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" align=center 
            bgColor=#006699 border=0>
              <TBODY>
              <TR bgColor=#006699>
                <TD id=white align=middle width=556 bgColor=#006699><FONT 
                  color=#ffffff>对该文的评论</FONT> </TD></TR></TBODY></TABLE>
            <DIV align=right><A id=CommnetList1_CommnetList1_Morelink 
            href="http://comment.csdn.net/Comment.aspx?c=2&amp;s=14697">【评论】</A> 
            <A id=CommnetList1_CommnetList1_Hyperlink1 
            href="javascript:window.close();">【关闭】</A> 
      </DIV><BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></FORM><!-- 版权 -->
<HR align=center width=770 noShade SIZE=1>

<TABLE cellSpacing=0 cellPadding=0 width=500 align=center border=0>
  <TBODY>
  <TR>
    <TD vAlign=bottom align=middle height=10><A 
      href="http://www.csdn.net/intro/intro.asp?id=2">网站简介</A> - <A 
      href="http://www.csdn.net/intro/intro.asp?id=5">广告服务</A> - <A 
      href="http://www.csdn.net/map/map.shtm">网站地图</A> - <A 
      href="http://www.csdn.net/help/help.asp">帮助信息</A> - <A 
      href="http://www.csdn.net/intro/intro.asp?id=2">联系方式</A> - <A 
      href="http://www.csdn.net/english">English</A> </TD>
    <TD align=middle rowSpan=3><A 
      href="http://www.hd315.gov.cn/beian/view.asp?bianhao=010202001032100010"><IMG 
      height=48 src="制作java应用程序的帮助文件.files/biaoshi.gif" width=40 
  border=0></A></TD></TR>
  <TR>
    <TD vAlign=top align=middle>北京百联美达美数码科技有限公司 版权所有 京ICP证020026号</TD></TR>
  <TR align=middle>
    <TD vAlign=top><FONT face=Verdana>Copyright &copy; CSDN.NET, Inc. All Rights 
      Reserved</FONT></TD></TR>
  <TR>
    <TD height=15></TD></TR></TBODY></TABLE><!-- /版权 -->
<SCRIPT>
      document.write("<img src=http://count.csdn.net/count/pageview1.asp?columnid=4&itemid=11 border=0 width=0 height=0>");
    </SCRIPT>
</BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -