gpt4 book ai didi

java 帮助文件未获取(.hs)

转载 作者:行者123 更新时间:2023-12-01 05:32:04 26 4
gpt4 key购买 nike

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

C:\Program Files\javahelp-2.0_05\demos\bin\hsviewer.jar

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

C:\Program Files\Java\jdk1.6.0_24\bin\java.exe 

我的项目在目录中创建

E:\java\databaserecord\src\HelpFile\javahelp

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

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

当我单击 HelpContent(menuItem) 时,它应该打开一个 Master.hs 文件,但我没有收到任何输出和错误。如果我打印 HelpSet 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 并且您试图声明一个方法?可能是这样的。我希望这对您有帮助:)

关于java 帮助文件未获取(.hs),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8817890/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com