- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的应用程序中,我动态加载 JavaHelp 的 jhall 文件,因此我的代码使用反射。奇怪的是,它在第一次调用时工作正常,并且我的 JavaHelp 屏幕显示良好,包含所有导航。如果我关闭 JavaHelp 屏幕,然后再次打开它,我会收到消息:
UIDefaults.getUI() failed: createUI() failed for javax.help.JHelpContentViewer[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=] java.lang.reflect.InvocationTargetException java.lang.Error
除了第一个请求之外,所有 JavaHelp 请求都会发生这种情况。但是,没有捕获任何异常,并且我 try catch createUI 错误,但也没有捕获任何内容(显然这并不奇怪)。这可能是一个类加载器问题 - 我对类加载器有点不稳定 - 但没有捕获任何异常......我真的需要一些帮助来解决这个错误。短暂性脑缺血发作
FWIW,(大部分)代码如下 - jHelpClass 和 helpSetClass 在其他地方声明...
jHelpClass = null;
helpSetClass = null;
URLClassLoader cl = null;
File jFile = new File(jhallJarFile);
if (!(jFile.exists())) {
JOptionPane.showMessageDialog(frame,"JavaHelp jar file shown in properties does not exist");
return;
}
try {
URI uri = jFile.toURI();
URL url = uri.toURL();
URL[] urls = new URL[]{url};
// Create a new class loader with the directory
cl = new URLClassLoader(urls, this.getClass().getClassLoader());
jHelpClass = cl.loadClass("javax.help.JHelp");
// Find the HelpSet file and create the HelpSet object
helpSetClass = cl.loadClass("javax.help.HelpSet");
} catch (MalformedURLException e2) {
} catch (ClassNotFoundException e2) {
} catch (NoClassDefFoundError e2) {
}
if (jHelpClass == null || helpSetClass == null) {
JOptionPane.showMessageDialog(frame,
"JHelp class or HelpSet class not found in jar file");
return;
}
// HelpSet hs = null;
URL url = null;
//Object hv = null;
JComponent hv = null;
try {
url = this.getClass().getClassLoader()
.getResource("helpSet.hs");
if (url == null) {
JOptionPane.showMessageDialog(frame, "HelpSet not found");
return;
}
Constructor conhs = helpSetClass.getConstructor(
ClassLoader.class, URL.class);
//Object hs = conhs.newInstance(null, url);
Object hs = conhs.newInstance(cl, url);
Constructor conjh = jHelpClass.getConstructor(helpSetClass);
hv = (JComponent) conjh.newInstance(hs);
} catch (Exception e2) {
JOptionPane.showMessageDialog(frame,
"HelpSet could not be processed: " + e2);
return;
}
// Create a new frame.
final JFrame frame2 = new JFrame();
frame2.setTitle("Help DrawFBP");
frame2.setIconImage(favicon.getImage());
//frame2.setRequestFocusEnabled(true);
frame2.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ev) {
if (ev.getKeyCode() == KeyEvent.VK_ESCAPE) {
//frame2.setVisible(false);
frame2.dispose();
}
}
});
// Set its size.
frame2.setPreferredSize(frame.getPreferredSize());
// Add the created helpViewer to it.
frame2.getContentPane().add(hv);code
// Set a default close operation.
frame2.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// Make the frame visible.
frame2.setVisible(true);
frame2.pack();
return;
最佳答案
事实证明,我可以通过卡在名为“hv”的变量(JHelp 实例)上来解决这个问题,而不是每次都重新计算它 - 显然所有重新加载都以某种方式损坏了存储中的类......?不知道这是否有意义,但我的应用程序目前正在运行。我有兴趣更多地了解导致此问题的真正原因,以及将来是否有解决问题的技术,但显然解决方案不再紧迫!感谢所有为此花费时间的人。
关于JavaHelp 的 Java newInstance 调用在第二次及后续调用时崩溃并出现 createUI 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15116872/
我希望能够从类路径之外的自定义位置加载 javahelp 内容。此位置可能会在应用程序的生命周期中发生变化,并且可能位于共享网络设备上。 不幸的是,HelpSet 类需要类加载器,所以我猜我的帮助集文
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭2 年前。
我正在 NetBeans 中使用 java swing 开发桌面应用程序 我想在应用程序中包含在线帮助 将javahelp库集成到系统中。 帮助集的元数据已创建。 但看起来我找不到链接 下载 java
Javahelp 是基于 Java 的帮助系统,可以轻松集成到 Java 应用程序中。该文档没有提供任何有关它的信息。在网络上,许多人表示这是不可能的,帮助浏览器始终使用内置字体。我不相信这是不可能的
我正在为应用程序(基于 NetBeans 构建)创建一些帮助内容,并认为在某些情况下能够在 JavaHelp 中显示教程视频或具有打开视频的链接会很有用。 我想可以使用 也许标记,但我不知道要嵌入哪个
我正在编写一些需要绑定(bind)帮助内容系统的应用程序。我遇到了JavaHelp这似乎非常适合我的需要。 我遇到的问题是,当您下载 JavaHelp 时,它带有自己的 bin 文件夹,看起来您应该单
我们有一个系统,其中前端要么是富客户端应用程序,要么是后端的 Web 界面。我们正在努力向我们的系统添加上下文相关帮助,但我们需要使用相同的基本配置文件 - 即上下文相关帮助文件需要相同,并且最好使用
我需要有关 JavaHelp 的帮助。上下文相关的帮助提供窗口级、字段级(如传递组件)。 但是当用户从树节点按下 HelpKey F1 或 JavaHelp 按钮时,我需要激活 JavaHelp(内置
在我的应用程序中,我动态加载 JavaHelp 的 jhall 文件,因此我的代码使用反射。奇怪的是,它在第一次调用时工作正常,并且我的 JavaHelp 屏幕显示良好,包含所有导航。如果我关闭
这篇文章的顶部较短的部分是我想要做的。第二部分是到目前为止已经完成的工作。它真的很长,但你应该能够从这里的顶部看到我在做什么。如果您对更多细节感兴趣,只需查看注释即可。 我正在使用 NetBeans
当我使用 HelpBroker.setCurrentID("[some help id]") 时,JavaHelp 正确显示了我想要的页面,但相关主题不会在目录中自动选择/突出显示。这使得用户很难知道
我正在尝试包含JavaHelp在我在 Eclipse 下开发的应用程序中。 我做了以下事情: 下载并解压JavaHelp library在我的项目工作区的子文件夹中。 将以下库的 JAR 添加到我的项
我是一名优秀的程序员,十分优秀!