Best way to make a game UI?

Hello there,

First of all, I have very little experience with graphical interfaces in Java, both in the “traditional” GUIs (Swing, SWT, etc) and in game development.

I was wondering what would be the best way to make the UI for a game. Particularly, chat: online games often offer a text field for chatting, and I’d like to know good ways to make one. The first obvious approach is writing your own editbox, but there are so many problems to deal with (cursor position and selection, cut/paste, keyboard shortcuts, input methods and other localization stuff, Unicode combining characters) I hope there are better ways.
I never really enjoyed Swing for its not-very-convincing pseudo-native look (and come on, Metal is awful), but as I’ve heard it’s possible to custom-draw its controls, they could be really handy for games. Is it possible to blend them with good performance graphics? Or are there better methods?

PS: sorry if this was already answered. I couldn’t find anything in my (rather poor) searches.

There are pre-written solutions that already do what you need. Here are a few of them, though only the first one will work right out of the box for you. The others are addons for particular libraries and use those libraries to perform drawing.

Feng GUI - I can’t seem to find the thread for this, but if you search for this around here, you’ll surely find it. It’s the farthest along of the 3 mentioned here.

SUI - UI library for Slick. This one’s well-written and maintained, but it’s an addon for Slick, so if you use it, you’ll need to bind it to whatever drawing routines you use.
http://slick.javaunlimited.net/viewtopic.php?t=187

GTGE GUI. Same deal as SUI. It’s well-implemented (though not finished), but it’s tied in to GTGE. However, GTGE just uses Graphics2D, so you may be able to use it with little modification. Watch the license though on this one.
http://www.goldenstudios.or.id/products/utilities/gui/index.php

  • Jon

Those libraries all sound good but FengGUI and Slick (as far as I know) are tied to openGL bindings and not Java2D (Graphics2D). You can use Swing in your games, just be aware of threading issues. Swing is handy since you can easily bundle a new look-and-feel by adding an extra jar file to the classpath and adding one line of code.

The only thing you have to be aware of are the threading issues. Swing’s Event Dispatch Thread is a big worry since you can not paint or modify it outside of the EDT.

Keith

Thanks for the replies!

I’ve checked them, and while FengGUI doesn’t seem to offer modal dialogs, it appears to be by far the most complete. I’m missing international character support (actually all the three suggested do), but I guess I can help improve the library and implement something :slight_smile: