什么';“我的程序出了问题,我总是出错”;arrow.java:42:错误:找不到符号;

什么';“我的程序出了问题,我总是出错”;arrow.java:42:错误:找不到符号;,java,javafx,Java,Javafx,我目前正在大学学习一些编程课程,我们正在做一项作业,创建一个箭头,它可以通过按键(R或B)和鼠标点击(左右)来改变颜色。我已经进行了大约一个小时的故障排除,我被这一个错误卡住了 “arrow.java:42:错误:找不到符号 SetTitle(“用键或鼠标给箭头上色”) 这是我的代码,如果它也有帮助的话 import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.layout.Stac

我目前正在大学学习一些编程课程,我们正在做一项作业,创建一个箭头,它可以通过按键(R或B)和鼠标点击(左右)来改变颜色。我已经进行了大约一个小时的故障排除,我被这一个错误卡住了

“arrow.java:42:错误:找不到符号 SetTitle(“用键或鼠标给箭头上色”)

这是我的代码,如果它也有帮助的话

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
    }
}

使用“setTitle”而不是“setTitle”

这是否回答了您的问题?
setTitle
您有一个输入错误,“setTitle”不是setTitle