java帮助文件没有得到(.hs)



我在项目中创建了一个类(javahelp),用于在单击帮助内容(菜单项)时获取java帮助文件。我更新了目录中已安装的javahelp-2.0_05

C:Program Filesjavahelp-2.0_05demosbinhsviewer.jar

然后Java exe文件包含在目录中

C:Program FilesJavajdk1.6.0_24binjava.exe 

我的项目是在目录中创建的

E:javadatabaserecordsrcHelpFilejavahelp

然后我更新了目录中的java帮助文件文件夹

E:javadatabaserecordbuildclassesjavahelp-2.0_05demoshsmergeMaster.hs 

当我单击HelpContent(menuItem)时,它应该会打开一个Master.hs文件,但我没有得到任何输出和错误。如果我打印帮助集URL,它会显示这行

file:/E:/java/databaserecord/build/classes/javahelp-2.0_05/demos/hs/merge/Master.hs

但它并没有打开帮助集页面。如何显示帮助集文件?

import java.net.*;
import javax.swing.*;
import javax.help.*;
import java.awt.event.*;

public class javahelp1 extends javax.swing.JFrame {

    public javahelp1() {
        initComponents();
    }
    //HelpSet hs;
     public void helpset(){
      try {
          ClassLoader cl = javahelp1.class.getClassLoader();
        URL hsURL = HelpSet.findHelpSet(cl, "javahelp-2.0_05/demos/hs/merge/Master.hs");
       System.out.println(hsURL);
      HelpSet hs = new HelpSet(cl, hsURL);
      HelpBroker hb = hs.createHelpBroker();
      new CSH.DisplayHelpFromSource(hb);
      } catch(Exception ee) {
          System.out.println(ee);
        System.out.println("HelpSet: "+ee.getMessage());
      }
   }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {
        jMenuBar1 = new javax.swing.JMenuBar();
        Mnu01 = new javax.swing.JMenu();
        Mnu02 = new javax.swing.JMenu();
        MnuItm01 = new javax.swing.JMenuItem();
        MnuItm02 = new javax.swing.JMenuItem();
        MnuItm03 = new javax.swing.JMenuItem();
        MnuItm04 = new javax.swing.JMenuItem();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setFont(new java.awt.Font("Arial", 0, 10));
        Mnu01.setMnemonic('F');
        Mnu01.setText("File");
        Mnu01.setToolTipText("Create a File");
        jMenuBar1.add(Mnu01);
        Mnu02.setMnemonic('H');
        Mnu02.setText("Help");
        Mnu02.setToolTipText("For Help");
        MnuItm01.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
        MnuItm01.setText("Content1");
        MnuItm01.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MnuItm01ActionPerformed(evt);
            }
        });
        Mnu02.add(MnuItm01);
        MnuItm02.setMnemonic('2');
        MnuItm02.setText("Content2");
        MnuItm02.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MnuItm02ActionPerformed(evt);
            }
        });
        Mnu02.add(MnuItm02);
        MnuItm03.setMnemonic('3');
        MnuItm03.setText("Content3");
        MnuItm03.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MnuItm03ActionPerformed(evt);
            }
        });
        Mnu02.add(MnuItm03);
        MnuItm04.setMnemonic('4');
        MnuItm04.setText("Content4");
        MnuItm04.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MnuItm04ActionPerformed(evt);
            }
        });
        Mnu02.add(MnuItm04);
        jMenuBar1.add(Mnu02);
        setJMenuBar(jMenuBar1);
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 587, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 309, Short.MAX_VALUE)
        );
        pack();
    }// </editor-fold>                        
    private void MnuItm02ActionPerformed(java.awt.event.ActionEvent evt) {                                         
           new javahelp2().setVisible(true);
}                                        
    private void MnuItm03ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        new javahelp3().setVisible(true);
    }                                        
    private void MnuItm04ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        new javahelp4().setVisible(true);
    }                                        
    private void MnuItm01ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            helpset();
    }                                        
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new javahelp1().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JMenu Mnu01;
    private javax.swing.JMenu Mnu02;
    private javax.swing.JMenuItem MnuItm01;
    private javax.swing.JMenuItem MnuItm02;
    private javax.swing.JMenuItem MnuItm03;
    private javax.swing.JMenuItem MnuItm04;
    private javax.swing.JMenuBar jMenuBar1;
    // End of variables declaration                   
}
public javahelp1(){

我对java还很陌生,但我唯一能注意到的是,在顶部,这就是你所说的。有没有可能你忘记说public void,而你正试图声明一个方法?这可能是一些类似的东西。我希望这是有帮助的:)

相关内容

  • 没有找到相关文章