相关疑难解决方法(0)

Eclipse 未运行 JavaFX 应用程序 - 运行“java”应用程序

每当我在 Eclipse 中创建项目并包含 javafx 时,单击运行按钮时应用程序都不会加载。

例如

package test;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class test extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Hello World!");
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
            }
        });

        StackPane root = new StackPane();
        root.getChildren().add(btn);
        primaryStage.setScene(new Scene(root, 300, 250));
        primaryStage.show();
    }
}
Run Code Online (Sandbox Code Playgroud)

这应该运行一个简单的 hello …

java eclipse macos javafx

4
推荐指数
2
解决办法
6264
查看次数

标签 统计

eclipse ×1

java ×1

javafx ×1

macos ×1