如何将Javafx安装到Eclipse

问题描述 投票:0回答:2

首先,我是Eclipse和Java的新手。所以,我的问题是,我无法将javafx安装到我的Eclipse。我安装了什么:https://www.oracle.com/java/technologies/javase-jdk13-downloads.html(Windows x64安装程序)https://www.java.com/de/download/win10.jsp(下载按钮)

我已经尝试过的:我遵循了有关如何安装Maven然后安装Javafx的指南:https://www.vogella.com/tutorials/EclipseMaven/article.html对于POM.xml文件,我使用了此链接中的代码:https://search.maven.org/remotecontent?filepath=org/openjfx/javafx/15-ea+1/javafx-15-ea+1.pom

现在,在创建一个新的Maven项目并尝试导入(例如javafx.scene.shape.Rectangle)之后,出现此错误:(导入jfxrt.jar之后)错误:缺少JavaFX运行时组件,并且是运行此应用程序所必需的]

我想运行的示例代码来自我的朋友:

    package vierGewinnt;

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class Game extends Application{

    public static void main(String[] args){
        launch(args);
    }

    public void start(Stage primaryStage){
        Field field = new Field();

        Button newGame = new Button("Neues Spiel");
        PositionColumn pos = new PositionColumn();



        VBox root = new VBox();
        root.getChildren().addAll(field, pos, newGame);
        Scene scene = new Scene(root);
        scene.addEventHandler(KeyEvent.KEY_RELEASED, new EventHandler<KeyEvent>(){
            @Override
            public void handle(KeyEvent event) {
                /*if(field.victory()){
                    Stage secondaryStage = new Stage();
                    HBox viBox = new HBox();
                    Scene viScene = new Scene(viBox);
                    secondaryStage.setScene(viScene);
                    secondaryStage.show();
                }*/
                if (event instanceof KeyEvent)
                    field.setStone(event);
            }
        });

        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

((还有其他类可以使用,那不是问题)

所以,在这一点上,我不知道下一步该如何工作,或者如何使javafx以另一种方式工作

首先,我是Eclipse和Java的新手。所以,我的问题是,我无法将javafx安装到我的Eclipse。我已经安装了什么:https://www.oracle.com/java/technologies/javase-jdk13 -...

javafx
2个回答
0
投票

您正在使用的JDK版本13不再包含JavaFX。因此,您需要将JavaFX手动添加到您的项目中。


0
投票

当我从@Tobias添加依赖项时,出现以下错误:

© www.soinside.com 2019 - 2024. All rights reserved.