JavaFX Stage not visible

匆匆过客 提交于 2021-01-29 16:18:35

问题


I'm trying to write the simplest code to start learning how JavaFX works. Here is my code:


package app;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class mainClass extends Application{

    Stage primaryStage;

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

    @Override
    public void start(Stage stage) throws Exception {

        primaryStage = stage;
        StackPane layout = new StackPane();

        Scene scene = new Scene(layout, 300, 300);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

It should just show an empty window. My compilator gives no errors, but nothing shows up, even if I can see my program running in my dock. How is this possible? I'm sure I'm missing some stupid simple thing, but I cannot figure out what it is.

来源:https://stackoverflow.com/questions/61308046/javafx-stage-not-visible

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!