运行示例文件时出现JavaFX错误
我尝试使用JavaFX从Oracle执行示例代码,我已经导入了JavaFX,但我一直收到相同的错误:运行示例文件时出现JavaFX错误,java,javafx,Java,Javafx,我尝试使用JavaFX从Oracle执行示例代码,我已经导入了JavaFX,但我一直收到相同的错误: SEVERE: javafx.scene.control.Control loadSkinClass Failed to load skin 'StringProperty [bean: Button[id=null, styleClass=button], name: skinClassName, value: com.sun.javafx.scene.control.skin.ButtonS
SEVERE: javafx.scene.control.Control loadSkinClass Failed to load skin 'StringProperty [bean: Button[id=null, styleClass=button], name: skinClassName, value: com.sun.javafx.scene.control.skin.ButtonSkin]' for control Button[id=null, styleClass=button]
java.lang.NullPointerException
at com.sun.t2k.MacFontFinder.initPSFontNameToPathMap(MacFontFinder.java:339)
at com.sun.t2k.MacFontFinder.getFontNamesOfFontFamily(MacFontFinder.java:390)
at com.sun.t2k.T2KFontFactory.getFontResource(T2KFontFactory.java:233)
at com.sun.t2k.LogicalFont.getSlot0Resource(LogicalFont.java:184)
at com.sun.t2k.LogicalFont.getSlotResource(LogicalFont.java:228)
at com.sun.t2k.CompositeStrike.getStrikeSlot(CompositeStrike.java:86)
at com.sun.t2k.CompositeStrike.getMetrics(CompositeStrike.java:132)
at com.sun.javafx.font.PrismFontUtils.getFontMetrics(PrismFontUtils.java:31)
at com.sun.javafx.font.PrismFontLoader.getFontMetrics(PrismFontLoader.java:466)
at javafx.scene.text.Text.<init>(Text.java:153)
at com.sun.javafx.scene.control.skin.LabeledText.<init>(LabeledText.java:31)
at com.sun.javafx.scene.control.skin.LabeledSkinBase.<init>(LabeledSkinBase.java:130)
at com.sun.javafx.scene.control.skin.ButtonSkin.<init>(ButtonSkin.java:45)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at javafx.scene.control.Control.loadSkinClass(Control.java:1044)
at javafx.scene.control.Control.access$500(Control.java:70)
at javafx.scene.control.Control$12.invalidated(Control.java:972)
at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:127)
at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:161)
at com.sun.javafx.css.StyleableStringProperty.set(StyleableStringProperty.java:71)
at javafx.scene.control.Control$12.set(Control.java:964)
at com.sun.javafx.css.StyleableStringProperty.applyStyle(StyleableStringProperty.java:59)
at com.sun.javafx.css.StyleableStringProperty.applyStyle(StyleableStringProperty.java:31)
at com.sun.javafx.css.StyleableProperty.set(StyleableProperty.java:70)
at com.sun.javafx.css.StyleHelper.transitionToState(StyleHelper.java:900)
at javafx.scene.Node.impl_processCSS(Node.java:7418)
at javafx.scene.Parent.impl_processCSS(Parent.java:1146)
at javafx.scene.control.Control.impl_processCSS(Control.java:1154)
at javafx.scene.Parent.impl_processCSS(Parent.java:1153)
at javafx.scene.Node.processCSS(Node.java:7386)
at javafx.scene.Scene.doCSSPass(Scene.java:454)
at javafx.scene.Scene.preferredSize(Scene.java:1468)
at javafx.scene.Scene.impl_preferredSize(Scene.java:1535)
at javafx.stage.Window$9.invalidated(Window.java:717)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:127)
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:161)
at javafx.stage.Window.setShowing(Window.java:781)
at javafx.stage.Window.show(Window.java:796)
at javafx.stage.Stage.show(Stage.java:233)
at application.Main.start(Main.java:26)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:219)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:182)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:179)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
SEVERE: javafx.scene.control.Control impl_processCSS The -fx-skin property has not been defined in CSS for Button[id=null, styleClass=button]
SEVERE: javafx.scene.control.Control impl_processCSS The -fx-skin property has not been defined in CSS for Button[id=null, styleClass=button]
SEVERE: javafx.scene.control.Control impl_processCSS The -fx-skin property has not been defined in CSS for Button[id=null, styleClass=button]
SEVERE: javafx.scene.control.Control impl_processCSS The -fx-skin property has not been defined in CSS for Button[id=null, styleClass=button]
SEVERE: javafx.scene.control.Control impl_processCSS The -fx-skin
为什么我会犯这个错误?我搜索了每个人关于这个bug的问题,它似乎是FX版本的问题,所以我更新到了2.3
我来自Java Swing背景,因此我不熟悉FX的所有配置细节,但这个简单的程序似乎应该运行…听起来您引入了版本问题。你的JDK版本是什么?对于版本8或更高版本以及标准的Oracle JDK,JavaFX包括在内,不应该单独安装。。。我安装了NetBeans IDE,在那里一切都正常,我只是更喜欢Eclipse,不明白它为什么不工作。重复:,但无法将其标记为这样,因为它没有可接受的答案。在对他们自己问题的评论中,原始海报写道:“将jdk-7改为jdk-8解决了问题”。你提到“这似乎是FX版本的问题,所以我更新为2.3”。我不明白。没有JavaFX2.3。这不是那篇文章的副本,因为改为jdk-8并没有解决它,我在询问之前阅读了这篇文章。我的意思是e(fx)Clipse2.3,抱歉弄错了@宝石海
package application;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
public class Main extends Application {
public void start(Stage primaryStage) {
try {
StackPane root = new StackPane();
Button btn = new Button("click here");
root.getChildren().add(btn);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.setTitle("NICHE Robot");
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}