Gbui in an applet

Hello everyone!

I've been having some issues with gbui in an applet with jme2 that I seem to have solved, but in a rather strange manner. I was hoping to get some insight on this.

I'm trying to use the gbui system by drawing directly on the glCanvas of my jme applet (I simply changed it to protected from private in the SimpleJMEPassApplet class).

CanvasRootNode c = new CanvasRootNode(glCanvas);

I used the same set of windows as in the gbui examples, and they displayed correctly, as I expected them to.

But when I closed (or maximized) them I got several nearly identical null pointer exceptions, usually like 5:

   at org.lwjgl.opengl.GL11.glDeleteTextures(
   at com.jme.scene.state.lwjgl.LWJGLTextureState.deleteAll(
   at com.jme.scene.state.lwjgl.LWJGLTextureState.deleteAll(
   at com.jmex.bui.BImage$1.releaseTextures(
   at com.jmex.bui.BImage.releaseTexture(
   at com.jmex.bui.BImage.release(
   at com.jmex.bui.text.AWTTextFactory$1.wasRemoved(
   at com.jmex.bui.Label$Text.wasRemoved(
   at com.jmex.bui.Label.wasRemoved(
   at com.jmex.bui.BLabel.wasRemoved(
   at com.jmex.bui.BContainer$3.apply(
   at com.jmex.bui.BContainer.applyOperation(
   at com.jmex.bui.BContainer.wasRemoved(
   at com.jmex.bui.BContainer$3.apply(
   at com.jmex.bui.BContainer.applyOperation(
   at com.jmex.bui.BContainer.wasRemoved(
   at com.jmex.bui.BWindow.setRootNode(
   at com.jmex.bui.BRootNode.removeWindow(
   at com.jmex.bui.BWindow.dismiss(
   at com.jmex.bui.listener.CollapsingWindowListener.close(
   at com.jmex.bui.listener.CollapsingWindowListener.actionPerformed(
   at com.jmex.bui.event.ActionEvent.dispatch(
   at com.jmex.bui.BComponent.dispatchEvent(
   at com.jmex.bui.BButton.dispatchEvent(
   at com.jmex.bui.BRootNode.dispatchEvent(
   at com.jmex.bui.BComponent.emitEvent(
   at com.jmex.bui.BButton.fireAction(
   at com.jmex.bui.BButton.dispatchEvent(
   at com.jmex.bui.BRootNode.dispatchEvent(
   at com.jmex.bui.CanvasRootNode.mouseReleased(
   at java.awt.AWTEventMulticaster.mouseReleased(
   at java.awt.Component.processMouseEvent(
   at java.awt.Component.processEvent(
   at java.awt.Component.dispatchEventImpl(
   at java.awt.Component.dispatchEvent(
   at java.awt.EventQueue.dispatchEvent(
   at java.awt.EventDispatchThread.pumpOneEventForFilters(
   at java.awt.EventDispatchThread.pumpEventsForFilter(
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(
   at java.awt.EventDispatchThread.pumpEvents(
   at java.awt.EventDispatchThread.pumpEvents(

Aside from these exceptions, the windows closed just fine. When maximizing, however, there were issues (the window started to blink and not display some of it's text).

So I went to the almost-top of the stack trace and poked around with the releaseTexture call, as it seemed the problem was simply that the release event of the mouse was being handled more than once.

So, I checked if this was in fact the case with a trivial little hack (which is commented out in this code piece):

    protected static TexturePool _texturePool = new TexturePool() {
//       public int j = 0;
        public void acquireTextures(TextureState tstate) {           
            //if(j++ < 1)
            tstate.apply(); // preload

//        public int i = 0;
        public void releaseTextures(TextureState tstate) {           
           //if(i++ < 1)

The println showed that these calls did in fact take place more than once. Also, the tstate.getNumberOfSetTextures() always returned 1, despite the deleteAll() calls.

I got it to work by accident when I left the println (in which i/j was incremented) before the if. No exceptions thrown, and everything closed/maximized as expected - even though it never got to the tstate.deleteAll() call. So I commented it out and now the GUI works, which seems rather strange to me.

Is there a more stable way to make this work in an applet? If not, I figured I could save someone else some poking around by posting this solution, even though it is kind of ugly. Perhaps drawing on the applet's canvas is not the best idea? Is there a better way?

And perhaps someone knows why the various input events are being handled more than once? Any insight would be greatly appreciated.

Thanks :).

Very intriguing.  I've used GBUI in several Applets, but not since JME2.  All of mine were JME1.0 or 1.1.

Send me your code for this Applet and I'll run it through the rigors.

Just to make sure of everything: You're using GBUI from the trunk tip and JME2.

my email is standtrooper AT gmail DOT com

As soon as I get it, I'll hook it up to the GBUI Labs supercomputer and see what's going on.


Correct, I'm using GBUI from the trunk, and JME2.  GBUI has been set up according to the instructions of setting it up in eclipse, JME2 has a modified com.jme.util.Debug class with the debug values set to true, because they wouldn't automatically get that value in an applet for a reason I didn't care enough to investigate.

Email sent; thanks :).