JavaFX loadSkinClass失败 [英] JavaFX loadSkinClass Failed

查看:104
本文介绍了JavaFX loadSkinClass失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JavaFX的新手,所以我的问题可能非常基础。我正在尝试使用按钮创建一个简单的窗口,但我遇到了这个错误:

I am new to JavaFX, so my question might be really basic. I am trying to create a simple window with a button but I am stuck with this error:

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:232)
    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:451)
    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:7419)
    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:7387)
    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:716)
    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:779)
    at javafx.stage.Window.show(Window.java:794)
    at javafx.stage.Stage.show(Stage.java:230)
    at edu.troupmar.aop.hw_01.Applet.start(Applet.java:34)
    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]

这是我的代码:

public class Applet extends Application {

    Button button;

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception {
        stage.setTitle("Title of the Window");
        button = new Button();
        button.setText("Click me");

        StackPane layout = new StackPane();
        layout.getChildren().add(button);
        Scene scene = new Scene(layout, 300, 250);
        stage.setScene(scene);
        stage.show();
    }

}

窗口本身会出现,但是按钮不是由于错误。

The window by itself appears but the button does not due to the error.

感谢您的任何重播!

推荐答案

将JavaFX版本从2.1更新到2.2帮助我解决了这个问题。

Updating JavaFX version from 2.1 to 2.2 helped me resolve this issue.

这篇关于JavaFX loadSkinClass失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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