java 我在扩展“Application”类时不断收到错误

ajsxfq5m  于 2023-04-19  发布在  Java
关注(0)|答案(1)|浏览(104)

我尝试使用JavaFX,但在使用JavaFX中的任何内容时总是出现错误:

Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: Uncompilable code - cannot find symbol
symbol: class Application

这就是代码:

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

public class NewClass extends Application {

        public void start(Stage stage) {
        Circle circ = new Circle(40, 40, 30);
        Group root = new Group(circ);
        Scene scene = new Scene(root, 400, 300);

        stage.setTitle("My JavaFX Application");
        stage.setScene(scene);
        stage.show();
    }
}
egmofgnx

egmofgnx1#

您可能正在使用不包含JavaFX的JDK。有各种方法可以科普这个问题。请查看官方文档:Getting Started with JavaFX

相关问题