简体   繁体   English

JavaFX Label扩展无法强制

[英]JavaFX Label extension unable to coerce

I'v extended a JavaFX Label. 我扩展了JavaFX标签。

public class UpdateLabel extends Label{
    private StringProperty updateKeyPrefix = new SimpleStringProperty();
    public String getUpdateKeyPrefix(){
        return this.updateKeyPrefix.get();
    }
    public void setUpdateKeyPrefix(String updateKeyPrefix){
        this.updateKeyPrefix.set(updateKeyPrefix);
    }

    private ObjectProperty<Enum<?>> updateKeyEnum = new SimpleObjectProperty<>();
    public Enum<?> getUpdateKeyEnum(){
        return this.updateKeyEnum.get();
    }
    public void setUpdateKeyEnum(Enum<?> updateKeyEnum){
        this.updateKeyEnum.set(updateKeyEnum);
    }

    public Update getUpdate(){
        return new Update(this.getUpdateKeyEnum(), this.getUpdateKeyPrefix(), null);
    }
}

Now when i use it in my fxml I get the following errors: 现在,当我在fxml中使用它时,出现以下错误:

在此处输入图片说明

I can still compile regardless, but when I run it I get this: 无论如何,我仍然可以编译,但是当我运行它时,我得到了: 在此处输入图片说明

Okay found it already: I wasn't extending the correct Label class. 好的,已经找到它了:我没有扩展正确的Label类。 (Java.awt instead of the JavaFX one). (用Java.awt代替JavaFX)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM