PR Merged and the library has updated to 1.1.4 on jcenter.
Hey @jayfella. I ran into an issue using this library with your JFX launcher. I get through the launcher but when trying to init JavaFxUI I get this:
Caused by: java.lang.IllegalStateException: Toolkit already initialized
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:182)
at javafx.application.Platform.startup(Platform.java:101)
at com.jayfella.jme.jfx.injme.JmeFxContainerImpl.initFx(JmeFxContainerImpl.java:647)
at com.jayfella.jme.jfx.injme.JmeFxContainerImpl.<init>(JmeFxContainerImpl.java:286)
at com.jayfella.jme.jfx.injme.JmeFxContainerImpl.install(JmeFxContainerImpl.java:79)
at com.jayfella.jme.jfx.injme.JmeFxContainerImpl.install(JmeFxContainerImpl.java:64)
at com.jayfella.jme.jfx.injme.JmeFxContainer.install(JmeFxContainer.java:24)
at com.jayfella.jme.jfx.JavaFxUI.<init>(JavaFxUI.java:55)
at com.jayfella.jme.jfx.JavaFxUI.initialize(JavaFxUI.java:99)
at com.dreamwagon.terranova.TerranovaApp.simpleInitApp(TerranovaApp.java:53)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:220)
at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:475)
at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:574)
at com.jme3.system.lwjgl.LwjglWindow.create(LwjglWindow.java:423)
at com.jme3.app.LegacyApplication.start(LegacyApplication.java:463)
at com.jme3.app.LegacyApplication.start(LegacyApplication.java:424)
at com.jme3.app.SimpleApplication.start(SimpleApplication.java:125)
at com.jayfella.launcher.controller.LauncherController.playButtonPressed(LauncherController.java:133)
... 63 more
I think this might be the issue. Not sure.
http://mail.openjdk.java.net/pipermail/openjfx-dev/2018-October/022610.html
Hm.
I wonder if putting Platform.exit()
just after this line will fix it.
I tested and that does not work:
Caused by: java.lang.IllegalStateException: Platform.exit has been called
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:177)
at javafx.application.Platform.startup(Platform.java:101)
at com.jayfella.jme.jfx.injme.JmeFxContainerImpl.initFx(JmeFxContainerImpl.java:647)
I believe the issue is that the launcher implicitly starts JavaFX by extending Application, so the explicit call to Platform.startup in JmeFxContainerImpl causes the IllegalStateException to be thrown. Maybe there needs to be a hook to notify that JavaFX is already started? I will look into it if I have time.
Edit: I created JmeFxContainerPreLaunchedImpl without the Platform.startup call in initFX and can confirm that resolves the issue.
are you sure its after the line he suggested? stacktrace show other method/line.
Yes. Line 101 of LaunchController is where I added the Platform.exit() call. That is not part of the stack I provided. The IllegalStateException is thrown from JmeFxContainerImpl which is in JavaFX JME, not the FX launcher codebase.
Does the library allow to embed a JME3 canvas/View into a javafx application?
No. What you describe is the other way around. It is possible by writing the last viewport frame buffer to a pixel writer. It is not in the scope of this project.
An old (not supported) jme-jfx integration out there allowed JME inside JFX once, but it was sloooooooow (IIRC, something like under 60 fps slow on a good pc, for a âhello worldâ). I wouldnât recommend bothering with it and I guess it only worked with Java 8 anyway. The other-way-around approach that jayfellaâs version uses is way, way faster.
Ok, to develop an editor , better add the gui on the top of the jme application.
I do have an implementation for such a thing, including input bindings, etc. You are correct that it would be a better solution. I may release the code at some point, but today is not that day My point is that it is entirely possible. I would refer you to the jmonkeybuilder project for most things. It contains all of the necessary code.
It is a JavaFx implementation of an editor. I think it uses java10. Thatâs important to know. I used lwjgl3 for some reason. Your mileage may vary.
Oh. Hereâs mine. It uses Java 11. You may find it of use.
Thanks for the sharing. I tried to build but I have some issues with gradle. I still take some inspiration from the sources .
@jayfella - Suggestion for the docs on GitHub.
You may want to include a notice that you need to use lwjgl3 and/or provide an example Gradle config for the core JME dependencies alongside jme-jfx, ex:
implementation âcom.jayfella:jme-jfx-11:1.1.5â
implementation â${jme3.g}:jme3-core:${jme3.v}â
implementation â${jme3.g}:jme3-desktop:${jme3.v}â
implementation â${jme3.g}:jme3-lwjgl3:${jme3.v}â
⌠as opposed to a lwjgl2 config from the JME webpage âQuick Startâ (great job with that by the way):
implementation â${jme3.g}:jme3-lwjgl:${jme3.v}â
which gives you one of these nasties:
java.lang.ClassCastException: class com.jme3.system.lwjgl.LwjglDisplay cannot be cast to class com.jme3.system.lwjgl.LwjglWindow (com.jme3.system.lwjgl.LwjglDisplay and com.jme3.system.lwjgl.LwjglWindow are in unnamed module of loader 'app')
Anyone else having issues with JFX cursors not showing up?
If I set the cursor property of a JFX node (for example, button.setCursor(Cursor.Hand)
), I would expect the cursor to change when mousing over it. However, the cursors never change from my desktop environmentâs default pointer cursor.
Iâm on Linux Mint, with a Gnome 3 desktop environment. I havenât yet confirmed whether or not non-JFX code can change the cursor via jMEâs InputManager
.
Yes, i have had that issue javafx in jme on windows as well.
So at this point itâs probably safe to assume that this is an issue with jME-JFX and is not platform specific.
Either that, or the cursor override functionality is meant to be triggered manually rather than automatically.
@jayfella do you know if there is something special that needs to occur for this, or is it something that can only be done in jme?
I suspect it may be because the button has several events that override the default style when theyâre triggered. Try setting it in an onMouseEntered event.
I have mine on an anchor pane attached to onMouseMoved without any luck. I have not tried on enter.