I'm going through some programming classes in college currently, and we're working on an assignment to create an arrow that can change colors with a keystroke (R or B) and a mouse click (Left and right). I've gone through troubleshooting for about an hour now, and I'm stuck on this one error.
"arrow.java:42: error: cannot find symbol primaryStage.SetTitle("Color an Arrow with Key or Mouse")
Here's the code I have if it helps too.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.shape.Polygon;
import javafx.scene.input.MouseButton;
import javafx.scene.input.KeyCode;
public class Arrow extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
StackPane pane = new StackPane();
//Create an arrow and place it in the pane
Polygon arrow = new Polygon();
arrow.setFill(Color.WHITE);
arrow.setStroke(Color.BLACK);
arrow.getPoints().addAll(50.0,50.0, 150.0,50.0, 150.0,0.0, 250.0,100.0, 150.0,200.0, 50.0,150.0);
pane.getChildren().add(arrow);
//Add a mouse click handler to the arrow
arrow.setOnMouseClicked(e -> {
if (e.getButton() == MouseButton.PRIMARY) {
arrow.setFill(Color.RED);
}
else if (e.getButton() == MouseButton.SECONDARY) {
arrow.setFill(Color.BLUE);
}
});
//Create a scene and place it in the stage
Scene scene = new Scene(pane, 400, 400);
scene.setOnKeyPressed (e -> {
if (e.getCode() == KeyCode.R) {
arrow.setFill(Color.RED);
}
else if (e.getCode() == KeyCode.B) {
arrow.setFill(Color.BLUE);
}
});
primaryStage.SetTitle("Color an Arrow with Key or Mouse"); // Set the stage title
primaryStage.setScene(scene); //Place the scene in the stage
primaryStage.show(); //Display the Stage
}
}