私はJava、特にfxmlを初めて使用します。私の質問が挑戦的でない場合は、ご容赦ください。私の問題: IDE に、「Modelll.Haushaltsverbrauch のインスタンスを FXML ローダーで作成できません」という警告が表示されます。公式のオラクル チュートリアル「Creating an Address Book with FXML」を参照したので、その理由はわかりません。
https://docs.oracle.com/javase/8/javafx/fxml-tutorial/fxml_tutorial_intermediate.htm
チュートリアルと比較して、コードを「zeitspanneproperty」という名前の 1 つの属性に減らしました。
私はFXML.fxmlを持っています
<TableView fx:id="tableView" layoutX="117.0" layoutY="-3.0" prefHeight="372.0" prefWidth="384.0" tableMenuButtonVisible="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columns>
<TableColumn text="Zeitspanne">
<cellValueFactory><PropertyValueFactory property="zeitspanneproperty" />
</cellValueFactory>
</TableColumn>
</columns>
<items>
<FXCollections fx:factory="observableArrayList">
<Haushaltsverbrauch zeitspanneproperty="365"/>
</FXCollections>
</items>
</TableView>
そして私の Haushaltsverbrauch.java
package Modell;
import javafx.beans.property.SimpleStringProperty;
public class Haushaltsverbrauch {
private final SimpleStringProperty zeitspanneproperty = new SimpleStringProperty("");
public Haushaltsverbrauch(String zeitspanne) {
setZeitspanneproperty(zeitspanne);
}
public final void setZeitspanneproperty(String zeitspanne) {
this.zeitspanneproperty.set(zeitspanne);
}
public String getZeitspanneproperty() {
return zeitspanneproperty.get();
}
}
Controller クラスと Application クラスは基本的に同じです。誰かヒントを教えてください!