【发布时间】:2020-02-22 08:54:52
【问题描述】:
首先,我是 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 以不同的方式工作
【问题讨论】:
-
JavaFX 不再是 JDK 的一部分(从 Java 11 开始)。见openjfx.io/openjfx-docs
标签: eclipse javafx installation