Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/355.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
GUI没有在Mac上使用Eclipse与JavaFX15一起显示_Java_Eclipse_Macos_User Interface_Javafx - Fatal编程技术网

GUI没有在Mac上使用Eclipse与JavaFX15一起显示

GUI没有在Mac上使用Eclipse与JavaFX15一起显示,java,eclipse,macos,user-interface,javafx,Java,Eclipse,Macos,User Interface,Javafx,我一直按照说明使用JavaJDK15和JavaFX15构建HelloWorldJavaFX应用程序。我已添加此处描述的运行配置:。当我在Mac上运行程序时,我的控制台中没有收到任何错误,但GUI没有出现。在我的Windows计算机上构建相同的应用程序,我能够构建并查看GUI Main.java package hellofx; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.

我一直按照说明使用JavaJDK15和JavaFX15构建HelloWorldJavaFX应用程序。我已添加此处描述的运行配置:。当我在Mac上运行程序时,我的控制台中没有收到任何错误,但GUI没有出现。在我的Windows计算机上构建相同的应用程序,我能够构建并查看GUI

Main.java

package hellofx;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        Parent root = FXMLLoader.load(getClass().getResource("hellofx.fxml"));
        primaryStage.setTitle("Hello World");
        primaryStage.setScene(new Scene(root, 400, 300));
        primaryStage.show();
    }


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

package hellofx;

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

public class Controller {

    @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 + ".");
    }
}
hellofx.fxml

<?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" xmlns:fx="http://javafx.com/fxml/1" fx:controller="hellofx.Controller">
    <children>
        <Label fx:id="label" text="Label" />
    </children>
</StackPane>

可以找到此问题的解决方案

转到主类的运行配置,并单击“参数” 选项卡上,取消选中显示“使用-XstartOnFirstThread”的框 使用SWT启动时的参数”