JMEDesktop: Swing within jME scene

Hi folks,

I have the pleasure to announce a new feature in jME: With JMEDesktop you can now use Swing components as in-game GUI. While there is still work to do (e.g. memory optimization) you can already have a look at TestJMEDesktop.

Advantages compared to other 3D gui kits:

  • All known widgets available
  • Standard Swing-GUI-builders can be used
  • Look&Feels (even Synth works)

    Known Shortcomings:
  • Swing imposes a lot of overhead
  • Component.requestFocus has no effect (e.g. Tab key to change focus does not work yet)
  • Typematic rate not regarded (no repeating keystrokes while holding key etc. yet)
  • JScrollPane needs repainting in JDK1.4 (see TestJMEDesktop source)
  • Heavyweight components are not/incompletely drawn (e.g. internal frame title bars on macosx theme)

    I tested this on many systems, however, because it is quite VM-dependent, please report any issues here.

    Best regards,


    Sample screenshot with custom L&F:

It works great, I only have one problem currently: in JEditorPane with HTML content links do not work.

This is a screenshot with a window using  JMEDesktop:

It makes GUI design so much easier.

i've allways had(and still have) a problem with that TestJMEDesktop hangs after a short while, or after pressing some button…running jdk 1.5.0_05…can't put my finger on what it is, gonna check further…

I had a problem with JTextPane and put some more widgets in TestJMEDesktop:

Galun, did you add link listeners or try making the pane uneditable?

Yes. I tested it first in an applet to be sure everything works in swing. Then I just copied everything into a JMEDesktop.

There is a HyperlinkListener and inside an applet it works fine. In JMEDesktop buttons react on a click, input boxes work fine but no links.

Another question: As JMEDesktop is a Quad with a texture, would it be possible to have a blend effect so that the widgets are half transparent?

I would like to get a similar effect as I had with a Text node as you can see here:

I added a listener to TestJMEDesktop that demonstrates the problem:

ENTERED and EXITED events work, but no ACTIVATED.

Hey, nobody said it does not work at all for him until now  :slight_smile:

Only MrCoder makes me a bit concerned about that hanging  :expressionless: - is it temporary or is the VM hung forever?

@Galun: half transparent? sure! - just do it like that text node

html-links: I don't know if I find the time to look at it soon. Most probably some mouse events are fired different by JMEDesktop than by a normal Swing Window. You can add a awt event listener at the toolkit and compare the event within your applet and in jME to get a clue…

Hey there.

I love this desktop feature but I have a problem.

I seem to get an openGL exception.

Does anyone know what this is or how to resolve it?

org.lwjgl.opengl.OpenGLException: Invalid value (1281)
   at org.lwjgl.opengl.Util.checkGLError(
   at com.jmex.awt.swingui.LWJGLImageGraphics.update(Unknown Source)
   at com.jmex.awt.swingui.ImageGraphics.update(Unknown Source)
   at com.jmex.awt.swingui.JMEDesktop.draw(Unknown Source)
   at com.jme.renderer.RenderQueue.renderTransparentBucket(Unknown Source)
   at com.jme.renderer.RenderQueue.renderBuckets(Unknown Source)
   at com.jme.renderer.Renderer.renderQueue(Unknown Source)
   at com.jme.renderer.lwjgl.LWJGLRenderer.displayBackBuffer(Unknown Source)
   at Source)
   at com.mw3d.gui.test.TestJMEDesktop.main(

uh, that looks ugly - does the TestJMEDesktop run correct? (I see the one with the error is your own one)

If no, could you please compile with debug switched on to get those line numbers for LWJGLImageGraphics.

Hey there irrisor.

Yes this is my own class, but I have copied the latest source from cvs for the file.

How do I active Debugger?

Also, what version of LWJGL are you using? 0.99?

tGiantLabs said:

How do I active Debugger?

The debug info is on by default as far as I know. "javac -g" forces it on

Also, what version of LWJGL are you using? 0.99?

The one that comes with jME - lwjgl 0.98.
If you are using 0.99 that might be a hint...

No I am not using lwjgl0.99, just asking?

And what version of jdk are you using?

I am using jdk1.4.2_08!

For that gl-error the jdk should not matter - graphics card and driver, chosen texture sizes etc. would be important.

FYI though - systems tested by me are:

Pentium M + Radeon 9200,

Pentium IV (hyperthreading) + Geforce FX 9500,

AMD Athlon + Geforce FX 9200,

AMD64 + Radeon 9600

on Gentoo Linux stable / Windows XP Pro (both on all Systems) with JDK 1.4.2_10-b03 and JDK 1.5.0_05-b05 each

Mac mini, JDK 1.4.2_09-233 on MacOSX 10.3.9 and JDK 1.5 on MacOSX 10.4

Well, I am using a system with


Graphics card: Intel® 82915/GV/910GL Express Chipset. (Maybe this is the problem)

CPU: Pentium 4

Ram: 2Gb

Well, I don't know what is up.

The swing stuff is rendered, but as soon as I hover or click on a button I get that error.

tGiantLabs said:

The swing stuff is rendered, but as soon as I hover or click on a button I get that error.

That sounds like a problem with updating parts of the texture. Maybe that card supports only specific region sizes to update. I have added a fallback to updating the whole desktop each time it is drawn - please test if this helps. This makes painting quite slow on those cards but should keep functionality (a warning is printed and e.g. dragging frames around gets slow).

Thanks, I found the problem.

There seems to have been a problem with my graphics card properties.

I restored all the properties to default and whalla, it worked!


Now, can one set a swing component to be transparent? Apply a alpha state to it?

Great that it works  :slight_smile:

tGiantLabs said:

Now, can one set a swing component to be transparent? Apply a alpha state to it?

As you see on the screenshot above - you can  :)
But obviously alpha states cannot be assigned to components  ;) - just normal swing transparency.
But if your components are not transparent themselfes you can do something like

jmeDesktop.setColorBuffer( null );
        jmeDesktop.setDefaultColor( new ColorRGBA( 1, 1, 1, 0.3f ) );

to make the whole desktop transparent.

just wondering but could this be used like the gui in doom 3?

wakeboardin said:

just wondering but could this be used like the gui in doom 3?

Hah, yeah I thought exactly that same when I started the test demonstration of it!  :D

Judging by the demonstration, I can't see why it couldn't be used like they do in Doom 3. It might even be pretty easy to implement once the last bugs are cleared out. I'd also be easy to make a 3D-ish game menu with it by using some rotation and translation like in the demonstration :)

It looks really interesting!