Swing in jMonkey, not jMonkey in Swing

If I search for Swing and jMonkey I only find questions about how to embed a JMonkey panel in Swing.

Swing is lightweight, i.e. everything is painted first, the result is displayed.

Has anyone tried to paint on a texture (instead of getContentPane () of a JFrame) to embed Swing application inside jMonkey (really inside the 3d)?
Thx.

Hmm, I have not seen it done, but it would probably be similar to how the jfx implementation for jme would work. But I do not know.

I do know that in platforms other than Windows, awt based things have a tendency to break lwjgl’s opengl hooks. So if someone did do something for Swing in jme, it would probably only work on Windows.

Quote:
Unlike AWT components, Swing components are not implemented by platform-specific code. Instead, they are written entirely in Java and therefore are platform-independent.
Swing “paints” its controls using the Java 2D APIs, rather than calling a native user interface toolkit. Thus, a Swing component does not have a corresponding native OS GUI component, and is free to render itself in any way that is possible with the underlying graphics GUIs.

So I think a platform Windows or not Windows has nothing to do with it. Swing paints “pictures” that look like an application. When I display the “pictures” on a mesh using texture, it’s like loading JPGs into a texture. I can reproduce mouse events using rays … I think so.

Yes, Swing will work on any platform, but Swing only works in the same application as LWJGL in Windows.

This is how the javafx in jme works from a abstract level.

Swing uses AWT. It paints its own components but it ultimately does it to an AWT window (normally) and starts the AWT thread, etc… which is the issue with lwjgl3.

What kind of UI are you trying to make?

Okay then it doesn’t work, I just thought:

The question here is how do I replace JFrame or sun.java2d.windows.GDIWindowSurfaceData so that I can do without sun.awt.windows.WFramePeer at all.

Perhaps I would have to replace sun.java2d.windows.GDIWindowSurfaceData with something like x.y.z.jMonkey.TextureData in sun.java2d.SunGraphics2D … Or derive a new JMonkeyTextureGraphics2D directly from Graphics and insert it into the JFrame. It’s just an idea …

But note that there are UI library alternatives that are lighter weight depending on what you need.

So that’s why I was wondering what kind of UI you will make.

I’m a Swing-fanboy to be sure but the only way it makes since in a game is:

  1. “I already know swing really well and my UI will be very complicated.”
  2. “I’m making a game with a 1998-style UI and just want that old school look.”

Else it might be worth considering alternatives. (For example, as a Swing-fanboy, I wrote Lemur to be very swing-like in its approach to UI creation… it just lacks some built-in GUI elements that you’d have to make yourself… if you even need them.)

1 Like

Javafx is also a good alternative if you want something a little heavier that utilizes a prebuilt UI with a lot of tooling.

I have used Lemur and Jfx in jme project, both are great options that the community here knows a lot about and can help support.

1 Like

I know JTable and JTree well. That’s right.
Don’t care. I’m not a fan. I just had something there.

I don’t just want a game, I also want a game logic editor that looks more like a modeling component of a life insurance than a game - and in full screen.

Now I will forget fullscrenn. I have to build AWT or Swing or JavaFX with a 3d panel in there.

Thanks for the answers!

P.S. (is not so easy to let go)

I am currently looking at Nifty GUI - Wiki, there is TreeBox, but no table.

So maybe I should learn Nifty first.

I would recommend against Nifty, it is very old and not maintained at this point.

2 Likes

I would agree with @tlf30 about not using Nifty

I started my project using Nifty for the entire gui, and eventually threw away all my Nifty code and redid the GUIs with Lemur instead. It was a big loss but it was more than worth it considering how much more capable Lemur is than Nifty.

6 Likes

I had the same experience (years of using Nifty, hating it, and then swapping out to something else, JavaFX in my case). The wiki very much pushes people in the nifty direction. Would it make sense for the wiki to list out all the GUI options?

2 Likes

Yeah it looks like our wiki currently only mentions Nifty in the GUI section

We should probably not have Nifty listed first, and also add a section for Lemur/JFX/any more stable gui libraries, even if its a short page linking to a forum thread for each, so that new users at least know they exist and that Nifty is not the recommended library as it currently seems on the wiki.

I did not find out about Lemur until I joined the forums which was a few months after starting my project, so unless new engine users join or frequently lurk the forums early on, then they will likely only know about things if they are in the wiki.

4 Likes