加载 JavaFX Applet 时启用调试日志
我的 JavaFX 应用程序在通过 JavaFX Eclipse 插件执行时正常工作。
但是当我尝试将它嵌入到我的网络项目中时,它没有正确渲染,过了一会儿,一个黑色矩形被加载到它的位置。
这是加载我的 JavaFX 应用程序的代码:
<script src="http://dl.javafx.com/1.2/dtfx.js"></script>
<script>
javafx({
codebase: "/applets/",
archive: "HelloApplet.jar",
draggable: false,
width: 250,
height: 80,
code: "hello.HelloApplet",
name: "HelloApplet"
});
</script>
这是我的 JavaFX 应用程序的代码:
package hello;
// some imports here
// ...
Stage {
title: "My Applet"
width: 250
height: 80
scene: Scene {
content: Text {
x: 10 y: 30
font: Font { size: 24 }
fill: Color.BLUE
effect: DropShadow{ offsetX: 3 offsetY: 3}
content: "Hello World!"
} // Text
} // Scene
} // Stage
在我的 Web 项目中,我已将生成的 HelloApplet.jar 放入:
src/main/webapp/applets/HelloApplet.jar
但无济于事,它仍然没有加载我在这里做错了什么?我错过了什么吗?
加载小程序时是否可以启用任何日志记录?
My JavaFX app is working when executed via the JavaFX Eclipse plugin.
But when I try to embed it into my web project, it is not being rendered properly and after a while a black rectangle is loaded in it's place.
Here is the code for loading my JavaFX Application:
<script src="http://dl.javafx.com/1.2/dtfx.js"></script>
<script>
javafx({
codebase: "/applets/",
archive: "HelloApplet.jar",
draggable: false,
width: 250,
height: 80,
code: "hello.HelloApplet",
name: "HelloApplet"
});
</script>
And here is the code for my JavaFX App:
package hello;
// some imports here
// ...
Stage {
title: "My Applet"
width: 250
height: 80
scene: Scene {
content: Text {
x: 10 y: 30
font: Font { size: 24 }
fill: Color.BLUE
effect: DropShadow{ offsetX: 3 offsetY: 3}
content: "Hello World!"
} // Text
} // Scene
} // Stage
In my web project i have placed the generated HelloApplet.jar into:
src/main/webapp/applets/HelloApplet.jar
but to no avail it is still not loading what am i doing wrong here? am i missing something?
Is it possible to enable any logging while loading the applet?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
抱歉,我对 JavaFX 不够熟悉,无法帮助您解决此问题,但您可以查看控制台,以便通过在控制面板中启用它来查看堆栈跟踪和所有内容(如果您使用的是 Windows):
I'm sorry, I'm not familiar enough with JavaFX to help you with that, but you can view the console so you can see the stack traces and everything by enabling it in the Control Panel (if you're using Windows):
JavaFX 小程序使用新的 Java 插件架构,该架构使用 JNLP。要部署 JavaFX 小程序,您必须同时使用 html 文件和 jnlp 文件中的 javascript。当 IDE 生成 jnlp 和 html 文件时,它们会在这些文件中嵌入默认值,您必须确保这些值正确。在 Web 服务器上加载文件时,请确保以下事项:
archive:
键与 jar 文件的名称匹配。code:
键指向小程序的主类jnlp_href:
键指向 jnlp 文件的正确位置下面是一个示例:
javascript:
myapplet.jnlp
JavaFX applet uses the new Java-Plugin architecture which uses JNLP. To deploy JavaFX applets you must use both the javascript in html file and the jnlp file. When IDE's generate the jnlp and the html file, they embed default values in those files that you must ensure are correct. Make sure of the following when you load your files on the web server:
archive:
key matches the name of the jar file.code:
key points to the main class of the appletjnlp_href:
key points to the proper location of the jnlp fileBelow is a sample:
javascript:
myapplet.jnlp
您应该检查
JNLP
文件中codebase
的方向,其中应包含.jar
的正确路径。例如,如果我的
.jar
位于C:\Users\rodrigo\Documents\NetBeansProjects\JavaFXJavaScript\dist
,那么我的 JNLP 应该是http:// /localhost:8082/servlet/org.netbeans.modules.javafx.project.JnlpDownloadServlet/C%3A/Users/rodrigo/Documents/NetBeansProjects/JavaFXJavaScript/dist/
You should check the direction of
codebase
in fileJNLP
, which should contain the correct path of your.jar
.For example, if I have my
.jar
atC:\Users\rodrigo\Documents\NetBeansProjects\JavaFXJavaScript\dist
, then my JNLP should behttp://localhost:8082/servlet/org.netbeans.modules.javafx.project.JnlpDownloadServlet/C%3A/Users/rodrigo/Documents/NetBeansProjects/JavaFXJavaScript/dist/