0

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
    }
}
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • 1
    Does this answer your question? [What does a "Cannot find symbol" or "Cannot resolve symbol" error mean?](https://stackoverflow.com/questions/25706216/what-does-a-cannot-find-symbol-or-cannot-resolve-symbol-error-mean) – OH GOD SPIDERS Apr 12 '21 at 15:17
  • 5
    `SetTitle` <- My guess is that this should be `setTitle` as jva convention is that method names start with lower case. – OH GOD SPIDERS Apr 12 '21 at 15:19
  • 1
    You have a typo, 'setTitle' not SetTitle – DavidPi Apr 12 '21 at 15:19

1 Answers1

0

Use "setTitle" instead of "SetTitle"

cwittah
  • 349
  • 1
  • 3
  • 17