javaFX 2.0 中的 Application.launch() 问题

发布于 2024-12-22 05:41:41 字数 348 浏览 2 评论 0原文

在我的代码中,我使用 :

Application.launch(MyDesign.getClass(), null);

从单独的类运行 MyDesign 的 UI。 当它调用launch()时,它会执行MyDesign类的构造函数。我之前创建了一个 MyDesign 对象并初始化了它的属性。所以我在调用launch()后得到了一个新对象。 时,我需要停止调用其构造函数

Application.launch().

当我调用您的反馈 。谢谢。

In my code, I have used :

Application.launch(MyDesign.getClass(), null);

to run a UI of MyDesign from a seperate class.
When it calls launch(), it executes the constructor of MyDesign class. I have created a MyDesign object earlier and initialized its attributes. So I got a new object after calling launch(). I need to stop the calling its constructor when I call

Application.launch().

Your feed back is highly appreciated. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落墨 2024-12-29 05:41:41

不幸的是,您无法通过 Application.launch() 直接运行已创建的应用程序。

您可以使用下一个存根应用程序并启动它:

public class Runner extends Application {

    @Override
   public void start(Stage stage) throws Exception {
       myDesignInstance.start(stage);
   }
}

Unfortunately you can't directly run already created Application through Application.launch().

You can use next stub application and launch it instead:

public class Runner extends Application {

    @Override
   public void start(Stage stage) throws Exception {
       myDesignInstance.start(stage);
   }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文