网站重装后的JavaFX Platform.runLater() [英] JavaFX Platform.runLater() after site reload

查看:2394
本文介绍了网站重装后的JavaFX Platform.runLater()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写使用JavaFX嵌入Swing中的Java小程序。用户可以启动一个Swing的GUI使用JFXPanel具有以下code JavaFX组件:

I am writing an Java Applet using JavaFX embedded in Swing. Users are able to start a Swing-GUI with JavaFX components using JFXPanel with the following code:

group = AccessController.doPrivileged(new ProxyNewGroup());
fxPanel = new JFXPanel();
Platform.runLater(new Runnable() {
    public void run() {
        /* Create some objects and add them to group */
        ...
        Scene scene = new Scene(group);
        fxPanel.setScene(scene);
    }
};
jFrame.add(fxPanel);

当小程序启动,第一个用户可以创建GUI元素并将其关闭。后来,他可以重新创建。要做到这一点,我需要保持一种无形的JFrame containig一个JFXPanel在内存中运行时整体,我从来没有用,因为我读的地方,否则JavaFX的应用程序线程停止。现在的问题是,当用户重新加载页面的运行方式将不被执行,我没有得到任何错误消息或异常。

When the Applet starts first the user can create the GUI element and close it. Later he can recreate. To do so I need to hold an invisible JFrame containig a JFXPanel the whole runtime in memory, that I never use, because I read somewhere that otherwise the JavaFX-Application-Thread is stopped. The problem now is that when the user reloads the page the run-method won't get executed and I don't get any error message or exception.

我写了自己的类实现Runnable使用自定义构造函数。构造函数被调用,运行到结束,但运行方式不会上手。我也试着做了AccessController内的所有工作,但是这也没有工作。

I wrote an own class implementing runnable with a custom constructor. The constructor is called and runs till the end but the run-Method wont get started. I also tried do all work within the AccessController, but this also didn't work.

我真的不就没怎么解决这个问题和AP preciate任何帮助。先谢谢了。

I really don't no how to solve this problem and appreciate any help. Thanks in advance.

更新

我尝试了一些更多的东西:

I tried some more things:


  1. 我examinated正在运行的线程。当我开始Applet的图形用户界面有一个JavaFX应用程序线程和线程QuantumRenderer。当我重新加载网页,线程不会再出现。 Whenn重新加载页面befor我打开了GUI(并创建线程)一切工作正常,但afert第二次重装失败。

  1. I examinated the running threads. When I start the Applet-GUI there is a JavaFX Application Thread and a QuantumRenderer thread. When I reload the webpage, the threads won't show up again. Whenn reloading the Webpage befor I opened the GUI (and create the threads) everything works fine, but afert a second reload it fails.

我尝试使用的 Platform.setImplicitExit(假)的。有了这个选项我不需要我的背景对象了。当重新加载网页我得到的 QuantumRenderer-0未捕获:java.lang.IllegalMonitorStateException 的与Java控制台关闭。当启动小程序一切正常,我的电脑上很好,但我不想崩溃的Java而这种做法并没有在不同的PC机相同的Java版本的工作(8)。

I tried using Platform.setImplicitExit(false). With this option I don't need my background-object any more. When reloading the webpage I get a QuantumRenderer-0 uncaught: java.lang.IllegalMonitorStateException and the Java Console closes. When starting the Applet everything works fine on my computer, but I don't want to crash Java and this approach didn't work on a different pc with same Java-version (8).

这也许是信息有帮助的。

Maybe this informations are helpfull.

推荐答案

不知道,如果你解决了这个,但也许这的 http://news.kynosarges.org/2014/05/01/simulating-platform-runandwait/ 可以帮你。

Not sure if you solved this, but maybe this http://news.kynosarges.org/2014/05/01/simulating-platform-runandwait/ can help you

runLater吞下了所执行的动作可能会引发任何异常,
  因为它的设计没有任何沟通返回给调用者。如果
  你想错误处理需要专门runAndWait了
  Runnable的子类,它提供了这样的通信

runLater swallows any exceptions that the executed action might throw, as it’s not designed to communicate anything back to the caller. If you want error handling you need to specialize runAndWait for a Runnable subclass that provides such communication

这篇关于网站重装后的JavaFX Platform.runLater()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆