Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCharles Harpke
33,986 PointsUnable to run...error: Error:(29, 26) java: method addAll in interface javafx.collections.ObservableList<E> cannot be a
I receive the above error resulting from line 26 and 29...here is my code:
package sample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import java.awt.*;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
//Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
Group root = new Group();
Text txt = new Text("Sup?");
TextField nameFld = new TextField();
Button btn = new Button();
btn.setText("Say Sup!");
btn.setOnAction(evt -> System.out.printf("Sup %s!%n",
nameFld.getText()));
txt.setY(50);
VBox box = new VBox();
box.getChildren().addAll(txt, nameFld, btn);
root.getChildren().add(box);
primaryStage.setTitle("Sup");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
3 Answers
Craig Dennis
Treehouse TeacherOh noes! Burned by the blasted wrong import bug of JavaFX
Remove this offender:
import java.awt.*;
Craig Dennis
Treehouse TeacherI think the error probably pointed to java.awt.Button
. I smelled it because I've done that...a lot.
Charles Harpke
33,986 PointsCool...ty Where in the error message would that have tipped me?