As I embark on my latest project again I'm trying another different set of core data structures, which in turn requires a custom level editor. Which I don't mind, and is usually quite a bit of fun to put together, but this time I'm avoiding Awt/Swing altogether and creating the whole interface in openGL (but 2d only, hence the topic living in this forum).

My main questions for building a Gui framework would be:

How to handle mouse clicks

How to deal with components expanding past their parent bounds (combo box drop down lists etc.)

Dealing with dragging

Mouse focus (active or require click?)

I'm still designing on the fly (a Bad Thing most of the time, so most of my current code will probably go out the window) but if the whole project stays on triack then i'll probably release the gui stuff as a separate library for anyone who wants to use/abuse it..

I don't know if you'd consider this, but we're probably going to need someone to help with a GUI for the Java Open-Source RTS @ http://www.stardart.net/jos-rts/ . On the flipside, you could probably get some help (I know I'm interested in developing GUI components) this way as well.

One big problem (IMO) right now is that a lot of the developers there are afriad of working with OpenGL, and seeing as you are the only person whose really written a working game with the LWJGL, your input would really just be appreciated in general . Right now we're debating whether or not to tough it out with the Sun fullscreen stuff or go with an OGL wrapper..

Yeah the demo is really going to be nice - will finally show of that lwjgl *is* a good approach for java games - ofcourse there is a steeper learning curve with OGL as opposed to AWT - but as Cas will demo, it is very doable. And his library is accessible too:http://sourceforge.net/projects/spgl

My main questions for building a Gui framework would be:How to handle mouse clicks.

Depends, if you are using some lower level library, use that to implement a Event system like in AWT/Swing

How to deal with components expanding past their parent bounds (combo box drop down lists etc.)

Normaly you arent allowed to draw outside those bounds.We solved the problem by making a popup panel which is drawn last over the rest.You might have an easier deal with this because you implement from scratch, we implemented on top of AWT

I've been keeping half an eye on the RTS game, but at the moment it seems a tad haphazard, but such is to be expected. I'd highly recommend usig LWJGL, and really much of the game code remains the same (I'd be willing to be that a Java2D version of CounterSheep or Gems could be done in a weekend). Give me a week of working on it and I should have a basic set of functionality up (got a draggable window working last night) and you can see if its the kind of thing could be of use...

Hey i have actually been working on a gui system for the java open source game and my own projects. I have used some of the swing design but trying to replace some objects with int properties.

There are two main classes, GComponent which is like the base component with all the normal methods and empty event methods,update(time), and abstract render().

The other class is GComponents which is the bridge between java's gui to mine. It contains event processing, update(time),render(g), etc.

I think the most important thing is getting events to the right component quickly. The hardest part has been getting mouse drag events to the scroll bar quickly.My last design used a kind of quadtree, which pre-computed the screen region of a component, so you just needed a array lookup. Just uses more memory.At the moment i wanted to get a game gui, so memory was more important.

The parent-child relationship is also important as it decides how you render and process events down the heirachy. As the last version contained a 1 component array, when a child was added to a parent, the childs index was added to the parents child list ( the list is a Trove IntArrayList ).

The JFrame that contains my system, calls GComponent.processXXXEvent(x,x,x), which then finds the matching component, calling the appropriate component.xxxEvent(); The big performace sucker is findComponent().

It would be cool to share some code, to get some different ideas. I have just put up a page with a few versions of the system with some screen shots and code. http://www.froggy.com.au/harleyrana/gui.html

I had the added challange of making it work in all the 1.1 VM's.What you mention about the find component is true, it takes some time to find the right component to send events to.I create a function in my Component class that would return the top most child that is under an absolute dimension.

Unfortunatly progress has come to something of a standstill while i figure out a good way to sort out texturing my maps. And after that I'll take a sabbatical from code and computers in all forms over xmas, so likely it'll be a while before it looks any different..

Hey that looks cool! So its a 2D gui being rendered over a 3D scene. I feel so inaduquate, my level editor is plane old 2D!

I was just thinking of a new method for sorting the components making it quiker to find.Instead of finding which area on a grid the component was in, i found which horizontal line it was on. For each line i know the index of the components on it.

This method uses less memory than the grid because the grid needs to be fairly fine, and is a fixed size. Where as the each line can be spaced further apart, and uses only as much as needed.

Tell me what you think. You can see its not optimized, im still working on the idea.

[this code has been tested and edited, and now works]Also how do i get my formating to stay?

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org