マイコード:JavaFXを使用しています--All(テキストフィールド、テキストエリア、文字列)を追加できません。私はできないはずですか?
public class Main extends Application {
TextArea area = new TextArea();
TextField field = new TextField();
String text = "";
public void start(Stage primaryStage){
VBox pane = new VBox();
Button next = new Button("Next");
next.setOnAction(e->{
text+= "\n" + field.getText();
area.setText(text);
});
pane.getChildren().addAll(area,field,next);
Scene scene = new Scene(pane, 700, 300);
primaryStage.setTitle("CosmicWimpout");
primaryStage.setScene(scene);
primaryStage.show();
}
エラーが.addAll
上で、エラーが読み取ります
The method addAll(int, Collection<? extends Node>) in the type List<Node> is not applicable for the arguments (TextArea, TextField, String).
だから私はちょうど.addAll(面積、フィールド、次の)を含むように私のポストを編集しました。これらはすべてGUIノードですが、.addAllメソッドはこれらのパラメータを受け入れません。
'VBox'に' String'を追加するときに何が起こると思いますか? 'Node'sだけを受け付けます。 – Itai
ボタンノードであるnextを使用するように編集されたコード。まだ問題。 –
それはうまくいくはずです。 [mcve](http://stackoverflow.com/help/mcve)を作成し、それを含む質問を更新できますか?間違ったインポートでエラーが発生する可能性があります。 – Itai