イムJavaFXのコンボボックスに文字列を追加しようとしているが、私は上記のエラーを取得しておく:/
のJavaFX FXMLのコンボボックスのエラー
no suitable method found for add(String)
method Collection.add(CAP#1) is not applicable
(argument mismatch; String cannot be converted to CAP#1)
method List.add(CAP#1) is not applicable
(argument mismatch; String cannot be converted to CAP#1)
where CAP#1 is a fresh type-variable:
CAP#1 extends Object from capture of ?
CODE
room_id.getItems().add("Hello");
FXML
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.AutoMaven.ui.controller.ComboTestController">
<children>
<ComboBox fx:id="room_id" layoutX="170.0" layoutY="185.0" prefHeight="31.0" prefWidth="260.0" />
</children>
</AnchorPane>
を
更新
CAP#1のキャプチャからオブジェクトを拡張:CAP#1は、新鮮な型の変数であるところの文字列は、#1をキャップに変換することはできません:
は、リストを使用した後、私は
互換性のない型を取得しますか?
ObservableList<String> list=FXCollections.observableArrayList("1","2","3","4");
room_id.setItems(list);
他のコンパイラでコードをコンパイルしようとします。 –
コントローラに 'room_id'の宣言を表示できますか? –