从Oracle执行JavaFX FXML教程时出错 [英] Error when doing the JavaFX FXML tutorial from Oracle

查看:105
本文介绍了从Oracle执行JavaFX FXML教程时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早安, 我正在通过JavaFX FXML官方教程(请参见源代码此处).但是,当我使用Netbeans IDE编译它时,出现以下错误:

Good Day, I a working my way through the official JavaFX FXML tutorial (See source code here). However when I compile it using the Netbeans IDE I get the following error:

有人可以帮我吗

我正在运行JDK 1.7和JavaFX 2.0

I'm running JDK 1.7 and JavaFX 2.0

init:正在删除:
C:\ Users \ riash \ Documents \ Riaz \ Personal \ Java \ Samples \ FXMLExample \ build \ built-jar.properties
deps-jar:更新属性文件:
C:\ Users \ riash \ Documents \ Riaz \ Personal \ Java \ Samples \ FXMLExample \ build \ built-jar.properties
编译:检测到JavaFX Ant API版本1.1启动任务
从C:\ Program Files(x86)\ Oracle \ JavaFX 2.0 SDK \ tools \ ant-javafx.jar
签署JAR:
C:\ Users \ riash \ Documents \ Riaz \ Personal \ Java \ Samples \ FXMLExample \ dist \ FXMLExample.jar 到
C:\ Users \ riash \ Documents \ Riaz \ Personal \ Java \ Samples \ FXMLExample \ dist \ FXMLExample.jar 作为nb-jfx

init: Deleting:
C:\Users\riash\Documents\Riaz\Personal\Java\Samples\FXMLExample\build\built-jar.properties
deps-jar: Updating property file:
C:\Users\riash\Documents\Riaz\Personal\Java\Samples\FXMLExample\build\built-jar.properties
compile: Detected JavaFX Ant API version 1.1 Launching task
from C:\Program Files (x86)\Oracle\JavaFX 2.0 SDK\tools\ant-javafx.jar
Signing JAR:
C:\Users\riash\Documents\Riaz\Personal\Java\Samples\FXMLExample\dist\FXMLExample.jar to
C:\Users\riash\Documents\Riaz\Personal\Java\Samples\FXMLExample\dist\FXMLExample.jar as nb-jfx

警告:签名者证书将在六个月内过期.进入 密钥库密码:输入nb-jfx的密钥密码:正在启动 C:\ Program Files(x86)\ Oracle \ JavaFX 2.0中的任务 SDK \ tools \ ant-javafx.jar跳过jar复制到自身:FXMLExample.jar jfx-deployment:jar:运行:2012年6月19日晚上9:10:33 javafx.fxml.FXMLLoader logException严重:以下错误 发生在文件的第48行
/C:/Users/riash/Documents/Riaz/Personal/Java/Samples/FXMLExample/build/classes/fxmlexample/fxml_example.fxml[Ljava.lang.StackTraceElement;@1bb3a11
应用程序启动方法异常
java.lang.reflect.InvocationTargetException
在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:601)
在 com.javafx.main.Main.launchApp(Main.java:453)
在 com.javafx.main.Main.main(Main.java:537)

原因: java.lang.RuntimeException:应用程序启动方法
中的异常 com.sun.javafx.application.LauncherImpl.launchApplication1(未知 来源)com.sun.javafx.application.LauncherImpl.access $ 000(未知) 源代码)在com.sun.javafx.application.LauncherImpl $ 1.run(未知) 源代码
在java.lang.Thread.run(Thread.java:722)

由: javafx.fxml.LoadException:javafx.scene.layout.GridPane没有 默认属性.

Warning: The signer certificate will expire within six months. Enter Passphrase for keystore: Enter key password for nb-jfx: Launching task from C:\Program Files (x86)\Oracle\JavaFX 2.0 SDK\tools\ant-javafx.jar Skip jar copy to itself: FXMLExample.jar jfx-deployment: jar: run: Jun 19, 2012 9:10:33 PM javafx.fxml.FXMLLoader logException SEVERE: The following error occurred at line 48 in file
/C:/Users/riash/Documents/Riaz/Personal/Java/Samples/FXMLExample/build/classes/fxmlexample/fxml_example.fxml[Ljava.lang.StackTraceElement;@1bb3a11
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601)
at com.javafx.main.Main.launchApp(Main.java:453)
at com.javafx.main.Main.main(Main.java:537)

Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at com.sun.javafx.application.LauncherImpl.access$000(Unknown Source)
at com.sun.javafx.application.LauncherImpl$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:722)

Caused by: javafx.fxml.LoadException: javafx.scene.layout.GridPane does not have a default property.

推荐答案

将JavaFX运行时至少升级到2.1将解决您的问题.

Upgrading your JavaFX runtime to at least 2.1 will fix your problem.

您引用的样本源是为2.1运行时而不是2.0运行时设计的.

The sample source you reference is designed for a 2.1 runtime, not a 2.0 runtime.

新源与2.0不兼容的原因是2.1向Pane类添加了一个继承的@DefaultProperty批注(此批注的行为由GridPane继承).因此,当您使用2.1编写fxml时,可以省略某些默认标签,从而使2.1 fxml的冗长程度低于2.0所要求的. Dustin提供了完整说明马克思在他的博客中.

The reason the new source is incompatible with 2.0 is that 2.1 adds an inherited @DefaultProperty annotation to the Pane class (this annotated behaviour gets inherited by GridPane). Because of this, when you write fxml using 2.1 you can omit certain tags which get defaulted, making the 2.1 fxml less verbose than what is required for 2.0. A full explanation of this is provided by Dustin Marx in his blog.

这篇关于从Oracle执行JavaFX FXML教程时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆