2

I am quite new with java and especially with fxml. Please excuse if my question is not challenging. My problem: The IDE shows me the warning "Instance of Modell.Haushaltsverbrauch cannot be created by FXML loader". I do not now why as I orientated myself by the the official oracle Tutorial "Creating an Address Book with FXML"

https://docs.oracle.com/javase/8/javafx/fxml-tutorial/fxml_tutorial_intermediate.htm

In comparison to the tutorial I reduced my code to one attribute named "zeitspanneproperty".

I am having the 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>

And my 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 and Application class are basically the same. Can someone please give me a hint!

1 Answers1

3

I think that you got that error because your class Haushaltsverbrauch hasn't default constructor (constructor without parameters).

Add one and you'll be free from error.

ololo
  • 66
  • 3