JavaFX setIconified(false)不显示窗口

时间:2018-06-22 14:40:16

标签: javafx jax-rs jetty

我遇到的情况是,我有一个JavaFX应用程序,该应用程序允许主要阶段由一组REST端点进行图标化。这是应用程序代码:

public class server extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("/Hello.fxml"));

    Scene scene = new Scene(root, 300, 275);

    primaryStage.setTitle("FXML Welcome");
    primaryStage.setScene(scene);

    Server jettyServer = new Server(65534);
    ServletContextHandler context = new ServletContextHandler(jettyServer, "/");
    jettyServer.setHandler(context);

    final ResourceConfig rc = new ResourceConfig().register(
            new AbstractBinder() {
                @Override
                protected void configure() {
                    bind(primaryStage).to(Stage.class);
                }
            }
    );
    rc.packages("com.cognivue.jettypoc.rest");

    ServletHolder jerseyServlet = new ServletHolder(new ServletContainer(rc));
    jerseyServlet.setInitOrder(0);
    context.addServlet(jerseyServlet, "/*");


    jettyServer.start();



    primaryStage.show();
   }
}

这是REST控制器代码:

@Path("stagecontrol")
public class StageControl {

@Inject
private Stage primaryStage;

public StageControl() {

}

@GET
@Path("start")
public Response start() {
    Platform.runLater(() ->primaryStage.setIconified(false));
    return Response.ok().build();
}

@GET
@Path("stop")
public Response stop() {
    Platform.runLater(() ->primaryStage.setIconified(true));
    return Response.ok().build();
}
}

当我调用/ stagecontrol / stop时,该应用程序会图标化;当我打电话给/ stagecontrol / start时,什么也没发生。关于setIconified吗?

0 个答案:

没有答案