我想点击一下按钮打印出 Java很有趣,当我运行它时,我一直收到找不到符号错误。我不确定它是我的import语句还是代码本身的实际错误。我想知道是否有人可以帮我弄清楚为什么我会收到错误?
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
public class ButtonHandler extends Application {
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
Pane pane = new Pane();
Button btOK = new Button("OK");
pane.getChildren().add(btOK);
btOK.setOnAction((ActionEvent e) -> {
System.out.println("Java is Fun");
});
// Create a scene and place it in the stage
Scene scene = new Scene(Pane);
primaryStage.setTitle("Button Demo"); // Set title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
}
public static void main(String[] args) {
launch(args);
}
}