Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaFX应用程序未启动(MacOS使用JDK11)_Java_Eclipse_Macos_Javafx - Fatal编程技术网

JavaFX应用程序未启动(MacOS使用JDK11)

JavaFX应用程序未启动(MacOS使用JDK11),java,eclipse,macos,javafx,Java,Eclipse,Macos,Javafx,我正在尝试在Eclipse上运行JavaFX应用程序。代码基于“JavaFX和Eclipse”-->“IDE模块化”下的说明。但是,当我尝试运行应用程序时,不会出现任何窗口 我使用的是MacBook Pro 2018,唯一出现的是一张图片,上面有一杯咖啡放在码头上,名为“java”。我不能放弃。它退出和停止的唯一方法是从Eclipse强制终止程序 package org.openjfx; import javafx.application.Application; import static j

我正在尝试在Eclipse上运行JavaFX应用程序。代码基于“JavaFX和Eclipse”-->“IDE模块化”下的说明。但是,当我尝试运行应用程序时,不会出现任何窗口

我使用的是MacBook Pro 2018,唯一出现的是一张图片,上面有一杯咖啡放在码头上,名为“java”。我不能放弃。它退出和停止的唯一方法是从Eclipse强制终止程序

package org.openjfx;
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;


public class MainApp extends Application {

    @Override
    public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("scene.fxml"));

        Scene scene = new Scene(root);
        scene.getStylesheets().add(getClass().getResource("styles.css").toExternalForm());

        stage.setTitle("JavaFX and Gradle");
        stage.setScene(scene);
        stage.show();
    }

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

}

“scene.fxml”


展示您的工作。请发布fxml文件。还要检查是否存在任何异常,并将其发布。已添加。似乎没有例外,这正是我面临的问题。JavaFX很荒谬。展示你的作品。请发布fxml文件。还要检查是否存在任何异常,并将其发布。已添加。似乎没有例外,这正是我面临的问题。JavaFX是荒谬的。
module hellofx {

    requires javafx.controls;
    requires javafx.fxml;
    requires transitive javafx.base;
    requires transitive javafx.graphics;

    opens org.openjfx to javafx.fxml;
    exports org.openjfx;

}

package org.openjfx;

import javafx.fxml.FXML;
import javafx.scene.control.Label;

public class FXMLController {

    @FXML
    private Label label;

    public void initialize() {
        String javaVersion = System.getProperty("java.version");
        String javafxVersion = System.getProperty("javafx.version");
        label.setText("Hello, JavaFX " + javafxVersion + "\nRunning on Java " + javaVersion + ".");
    }    
}
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.StackPane?>


<StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.openjfx.FXMLController">
   <children>
      <Label fx:id="label" text="Label" />
   </children>
</StackPane>
.button {
    -fx-font-weight: bold;
}