LWJGL native window with Swing dialog

Started by Jesse, July 29, 2015, 22:36:54

Previous topic - Next topic

Jesse

I asked this over on the java-gaming forums, but thought I'd try here as well (perhaps I should've asked here first since it's an LWJGL question).

Would there be any problem with displaying a simple modeless Swing dialog along with an LWJGL 2.9.3 native window? Basically, all I want is to display a modeless dialog with some scrollable text and a 'close' button. The dialog doesn't have to be visible when the main window is in fullscreen mode.

This has worked on every machine I've tested it on, but based on my search of the forums here I'm still not quite clear on whether this would be reliable or not.

Would this be safe to do?

Cornix

I dont see why there should be a problem. Only one exception comes to my mind, perhaps MacOS might have problems because AWT code always has to run on the first thread, I am not sure whether LWJGL2 interferes with that.
Mind however that there is already LWJGL3 out there, you are using an outdated version.

Jesse

QuoteMind however that there is already LWJGL3 out there, you are using an outdated version.

Sure, I know about LWJGL 3 (there are a couple reasons I'm holding off on updating).

QuoteI dont see why there should be a problem. Only one exception comes to my mind, perhaps MacOS might have problems because AWT code always has to run on the first thread, I am not sure whether LWJGL2 interferes with that.

Yeah, threading concerns (especially with OS X) are one of the things I've been worried about, and so far I haven't really gotten a clear picture of whether LWJGL+Swing can be counted on to work in all cases.

In any case, it'd be nice to find an authoritative answer to this, but in absence of that I'll keep researching and see what I can figure out.

Thanks for your reply.

spasi

You could use a different process for the Swing window. It will work equally well with both LWJGL 2 and 3. The difficult part is using an off-heap message queue to communicate between the two processes. But there are plenty of Java libraries that do this kind of thing these days.

kappa

Not sure exactly what sort of dialog you want, but I did write some code to display a simple modeless dialog which might be useful to you. It works with LWJGL3 (should also work with LWJGL2), it can be found here.

Jesse

Thanks everyone for the replies. I'll admit I was hoping just to be able to display a simple Swing dialog without getting into multiple processes and so forth, but maybe that's not an option. Anyway, I'll look into the methods that were suggested.

Thanks again for the help.