Still no good solution for rich UI (JavaFX/Swing) + LWJGL?

Every so often over the last 10 years I check to see if there is a solution for integrating a rich UI like JavaFX or Swing with an LWJGL view. It seems like it should be easy but must be a really hard problem as it has remained unsolved for over a decade. There are lots of part solutions but they all wind up with deal breaker performance or cross platform issues.

Is anyone aware of any recent progress being made on this?

There’s JFXGL.
However it is not performant. It’ll slow to a crawl when you make complex UI’s. I tried to create an IDE using it, ran at 10 FPS with only UI code.

As for Java-based solutions, there’s:

I can’t speak for AUI or Legui, but @SkyAphid is constantly working on Clear, and I am constantly working on LWJGUI!
I’m currently working on a small game engine using LWJGUI

[EDIT]
I think I heard of some developments with actual integrations of JavaFX and LWJGL a few months back. Havent seen anything since.

Thanks for those links I’ll check them out. I would tend to avoid pet project GUI libraries due to the likelihood of them lacking important features and being abandoned at some point in future.

Backing this, LWJGUI is an amazing solution if you’re looking to get the fast and seamless JavaFX approach to making UIs. Definitely a deserved self-plug. My API is Clear, which is actually directly inspired by LWJGUI and is meant to be a bit harder to use but more flexible for the needs of what you’re making. Either solution will likely be more than capable of what you’re wanting and both of us are responsive to any bugs you may run into.

Clear might be for you in that case. I designed my library to essentially be as barebones/highly documented as possible so that if I did stop working on it, others can easily both continue working with/on it. If it’s missing something you want, I’ve made it very easy for you to attach it yourself with a plethora of examples.

Usually the things missing in personal gui projects include:

  • Dialogs and Windows with modal handling
  • Focus traversal
  • Animation
  • Clipboard handling
  • Lots of widgets (Spinners, Date Pickers, Sliders, Trees)

I think it is pretty hard to do a fully fledged GUI toolkit without a team of developers which is why it would be really nice if there was a hook in JavaFX for a native surface node you could attach a GL context to.

I don’t suppose anyone has tried using DriftFX (https://github.com/eclipse-efx/efxclipse-drift) to integrate LWJGL into JavaFX?

I didn’t try it, but I went through the link. Found this discouraging comment in the class.


//Note: this implementation is against internal JavafX API
@SuppressWarnings({"restriction", "deprecation"})
public class DriftFXSurface extends Node {

This is also the reason why integration with JavaFX is not pretty possible with good performance in LWJGL.

The closest that comes to JavaFX is LWJGLUI library written by @orange451. Most parts of it are resembling the JavaFX API itself. With some reflection, I think we can make a FxmlLoader to work with this.

There is also an imgui port we are mantaining here

Also, we have an experimental JavaFX branch

Sounds like a rich UI. Great to see.
I think that what ShannonSmith means by focus traversal is being able to use the tab key and shift tab to select different buttons and text input on the UI, and maybe also space or enter to activate.
Another thing that UI’s often lack is proper multi-line wrapping text entry. Of course this is an extremely laborious and difficult thing to code since it’s basically a word-processor.
I’ve always wanted to try using Java-CEF but haven’t had time:
https://bitbucket.org/chromiumembedded/
This is supposed to act as a web browser within a java application and might make a nice UI.
But maybe it’s silly since there’s little point using java at all in that case, may as well just use web pages, webGL and javascript in the browser.

Thanks, appreciated

Both the features are there

Or you could always embed a headless JVM in Electron for completely over-the-top bloat! ;D Actually, it’s not as stupid an idea as it sounds as Electron has useful desktop API’s too on top of CEF. I had a play with this last year using HTML4Java / DukeScript.

I haven’t ever properly tried immediate mode GUI’s. I think they require such a different mindset and I instinctively have concerns about how they scale (seems like a lot of work every frame). I did briefly try Nuklear because it can be easily bundled with lwjgl but never got very far because of the aforementioned mindset block. Might have to give it another try.

It’s a common worrying, however from some past tests I run with RemoteryGL, the demo example “weights” just 0.3ms to say

They shine especially for debugging and simple GUIs in production (take a look at some samples).

If you need it extensively in production (with a huge/complex usage) you shall fallback to the retained solutions.

Also, some interesting quotes