Trouble Getting Started with GBUI


Before I begin, GBUI looks like a great, well-designed GUI system for JME and I imagine it will save me lots of time. Thanks to everybody who contributed.

I'm having trouble getting it to run with JME. I set up a dummy project, just so I can play with GBUI. Just a BaseGame subclass with a single GameState, that renders a handful of primitives. I use the freshest GBUI from SVN, it's compiling in Eclipse, I can run the tests. In the dummy project, I copied the /rsrc/ folder straight-up from the SVN. I just want to reproduce the demos on top of my game.

So, to add GBUI to my project the first step was to add BuiSystem.init(); to my initSystem() overload, right after the display was set up. Next, in my GameState, I attached BuiSystem.getRootNode() to the rootNode after I added the aforementioned primitives.

My first bug was that calling BuiSystem.init() without arguments defaulted the style to look for "/rsrc/styles.bss", when the one in SVN is called "/rsrc/style.bss". That confused me, if that wasn't on purpose, it might be worth fixing. Regardless, that one was easy to figure out. :slight_smile:

I'm having more trouble figuring out my next bug. To get some GBUI onto my screen, I added this straight from one of the tests:

for (int i = 0; i < 3; i++) {
   BTitledWindow mw = MessageWindowUtil.createMessageBox("Window #"
         + i, "Window #" + i, TitleOptions.MIN_MAX_CLOSE,
         "Some content");

I put this after my scene has been set up (after adding the GBUI node to the root).

Now it crashes again with an NPE. BUT, it happens in the addWindow call. Here's the top of the trace:

   at com.jmex.bui.Label.layoutConfig(
   at com.jmex.bui.Label.computePreferredSize(
   at com.jmex.bui.BLabel.computePreferredSize(
   at com.jmex.bui.BComponent.getPreferredSize(

The null thing happens in when a BTextFactory tfact is called when null. It's set to null when the _container is asked for its getTextFactory(), and it doesn't have one.

So, I figure my problem is that the Style isn't loaded properly, and it's full of holes (probably not limited to that factory). Is that right? If so, how can I fix it? I'd love a dead-simple, ugly BSS I can use that will just let me fiddle with a GUI.

Sorry this got so long. Thanks for reading! If I get through this, I promise to write a tutorial for future generations. :)


I've got it!

Turns out that when I brilliantly copied the entire "/rsrc/" directory over to my dummy project, I neglected to consider how confused poor Java would get when I referred to "/rsrc/style2.bss" when there are a couple such directories kicking around the classpath! Turns out it had trouble dealing with the one it had chosen.

I renamed the one I wanted to use to something unique, and I was able to get some windows kicking around. I had been banging my head against GBUI for so long, and it turns out it actually was very simple, I just got things muddled. Once I'm more competent with this I'll throw a little guide up onto the Wiki so nobody has to go through that again. :slight_smile:



Glad to have another fan of GBUI!

Take a look and feel free to add what you can.  I had good intentions of adding more, but now I'm back from the sandbox and real life has taken all my time!  :smiley: