好吧,因为我无法以其他方式做到这一点,我发现使用默认用户浏览器查看文件更有用。所以这是我的解决方案:
helpItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Desktop desktop = null;
// Before more Desktop API is used, first check
// whether the API is supported by this particular
// virtual machine (VM) on this particular host.
if (Desktop.isDesktopSupported())
{
try
{
desktop = Desktop.getDesktop();
String thehelpfile= String.valueOf(getClass()
.getResource("help.html"));
File fileToOpen=new File(thehelpfile.substring(5));
desktop.open(fileToOpen);
} catch (IOException ex)
{
JOptionPane.showMessageDialog(null,
ex, "Λάθος", JOptionPane.PLAIN_MESSAGE);
}
}
}
});