JavaFX - TableView - setItems:TableView 类型中的方法 setItems(ObservableList) 不适用于参数 (ObservableList)

JavaFX - TableView - setItems : The method setItems(ObservableList) in the type TableView is not applicable for the arguments (ObservableList)

当我尝试将我的项目设置到 tableView 中时遇到问题,有关信息我使用 SceneBuilder。

Main.java :

public class Main extends Application {
private static Stage theStage;  
public static void main(String[] args) throws Exception {
    testDatas();
    launch();
}

public void start(Stage stage) throws IOException {
    theStage = stage;
    Group acteur = new Group();
    acteur.getChildren().add(
    FXMLLoader.load(getClass().getResource("views/options.fxml")));
    theStage.setTitle("Where's My Money");      
    Scene scene = new Scene(acteur, 1280.0, 720.0);
    theStage.setScene(scene);
    theStage.show();
}

public static void initialize() {
    launch();
}

public static void setScene(Group acteur, String titre) throws IOException {
    Scene scene = new Scene(acteur);

    theStage.setTitle(titre);
    theStage.setScene(scene);
    theStage.show();
}
}

views/ControllerOptions.class

public class ControllerOptions implements Initializable{

@FXML private TableView<?> TV_currency;
@FXML private TableColumn<Currency, String> TC_name;
@FXML private TableColumn<Currency, Double> TC_value;
private ObservableList<Currency> currencies = FXCollections.observableArrayList();

//FUNCTIONS
@Override
public void initialize(URL location, ResourceBundle rb){
    //initialisation Table Currencies
    for (Currency currency : Datas.getInstance().getCurrencies()) {
        currencies.add(currency);
    }       
    TC_name.setCellValueFactory(new PropertyValueFactory<Currency, String>("name"));
    TC_value.setCellValueFactory(new PropertyValueFactory<Currency, Double>("value"));
    TV_currency.setItems(currencies); // <= HERE'S THE ERROR
}
}

Models/Currency.class

public class Currency {

private String name;
private double value;

public Currency(String name, double value) {
    setName(name);
    setValue(value);
}

public void setName(String name) {
    this.name = name;
}
public String getName() {
    return name;
}

public void setValue(double value) {
    this.value = value;
}
public double getValue() {
    return value;
}
}

我有这个错误: TableView 类型中的方法 setItems(ObservableList) 不适用于参数 (ObservableList)

如果你能帮助我,我将不胜感激。

提前致谢

您将支持数据正确声明为

private ObservableList<Currency> currencies ;

但您使用通配符声明了 table:

@FXML private TableView<?> TV_currency;

因此,当您尝试在 table 中设置项目时,类型不匹配。

将 table 的声明更改为

@FXML private TableView<Currency> TV_currency;