Thanks.

-- Kevin


On 10/5/2018 12:10 AM, marcel Austenfeld wrote:
I created a bug report on https://bugs.java.com/
Bug ID is: 9057517
*Gesendet:* Donnerstag, 04. Oktober 2018 um 16:13 Uhr
*Von:* "Kevin Rushforth" <kevin.rushfo...@oracle.com>
*An:* "marcel Austenfeld" <marcel...@web.de>
*Cc:* openjfx-dev@openjdk.java.net
*Betreff:* Re: Aw: Re: "Toolkit already initialized" error with OpenJDK 11
I think I see what caused this. In FX 8 we called FXCanvas::initFx from
the constructor of every FXCanvas. It then called an internal startup
method, PlatformImpl::startup, that permits calling it when the Toolkit
is already initialized, turning it into a runLater if it is. As part of
the refactoring for FX 9 I changed it to call FXCanvas::initFx one time
from the static block. At the same time, I changed the startup call to
use the public Platform::startup method. This change was necessary
because the javafx.swt module does not have the needed qualified exports
to call internal methods until after initialization. The public
Platform::startup method is specified to throw an exception if called
more than once.

So if the FXCanvas class is loaded more than once, for example, if it is
called from different ClassLoaders, then that would cause the problem.
Please file a bug and I'll take a look at it. It might be as simple as
wrapping the call to Platform::startup in a try/catch and calling
Platform::runLater in the catch block.

-- Kevin


On 10/4/2018 6:03 AM, marcel Austenfeld wrote:
> Hello Kevin,
>
> I still have problems with the error: "java.lang.IllegalStateException: Toolkit already initialized".
>
> However I found out that this error only occurs if I call SWT FXCanvas classes located in different Eclipse plugins.
>
> I can create multiple JavaFX canvas if they are located in one Eclipse plugin.
>
> Vice versa if I try to to open the JavaFX SceneBuilder canvas which is located in a seperate Eclipse plugin this error occurs again.
>
> So I wonder that beginning with Java 9 the JavaFX toolkit doesn't recognize an already started toolkit in another Eclipse plugin (which was definitely the case with Java 8!).
>
> Maybee this has something to do with the new module system of Java >=9?
>
>
>
>
> Gesendet: Mittwoch, 26. September 2018 um 14:09 Uhr
> Von: "Kevin Rushforth" <kevin.rushfo...@oracle.com>
> An: "marcel Austenfeld" <marcel...@web.de>, openjfx-dev@openjdk.java.net
> Betreff: Re: "Toolkit already initialized" error with OpenJDK 11
> I'm' not aware of anything that intentionally changed between FX in JDK
> 8 and FX 11, but my guess is that the FX runtime is being shutdown after
> your first FXCanvas exits. Try making the following call (only needed
> one time) before creating your first FXCanvas:
>
>     Platform.setImplicitExit(false);
>
> -- Kevin
>
> On 9/26/2018 4:22 AM, marcel Austenfeld wrote:
>> First of all congratulation to the new release and thank you for the hard work on JavaFX.
>>
>>
>> I have a problem with JavaFX which in my case is embedded in a Rich Client Platform of Eclipse.
>>
>> I integrated several SWT FXCanvas (some with SwingNode panels as a SWT_AWT replacement) into my app.
>>
>> This works fine in Java 8 which my current release depends on.
>>
>> However in Java 11 after the second panel is initialized at startup I get the following error:
>>
>> "Caused by: java.lang.IllegalStateException: Toolkit already initialized"
>>
>> Is there a new option available to avoid a new initialization of the toolkit if several FXCanvas are embedded in an application? >> Or do you now any changes since Java 8 which could the cause of such an exception?
>>
>>
>> Thanks in advance for any help.
>

Reply via email to