I finally got around to extracting some of the semi-experimental UI components out into their own project: LemurProto.
The point of the LemurProto project is to incubate things that will eventually make it into Lemur core once they are hardened. I try very hard not to check in half-baked things into core… well, I try. LemurProto gives me (and others) a place to put things that may need a little work before being finalized.
Consequently, the GUI elements in LemurProto may change and break from one version to the next… part of the growing pains.
The project source can be found here:
https://code.google.com/p/jmonkeyplatform-contributions/source/browse/#svn%2Ftrunk%2FLemur%2Fextensions%2FLemurProto
And the current release is here:
https://jmonkeyplatform-contributions.googlecode.com/svn/trunk/Lemur/extensions/LemurProto/release/LemurProto.jar
Right now the main GUI element folks would be interested in is the ListBox and I’ve prioritized this motivated by @nehon so you can thank him.
By default, the list will render its elements as text labels and use a standard String.valueOf() for list model values. This behavior can be changed with cell renderers.
Basic usage is as follows:
[java]
VersionedList myList = new VersionedList(myListOfStrings);
ListBox listBox = new ListBox(myList);
[/java]
If items are added or removed from myList then the list box is automatically updated (thus the VersionedList).
Selection can be watched by grabbing a versioned reference to the selection model.
Custom renderers can be specified be setting the CellRenderer. A cell renderer can either create new cells every time it is accessed or it can reuse existing cells. One cell is created for every visible item in the list and as it is scrolled the renderer is asked for new cells (and can simply just reset the value of the existing one if it likes). This is slightly different than Swing’s model which tends to reuse on JLabel and uses it to paint every item (and then has tons of infrastructure built just to support using a Swing component to paint). Lemur opts to prefer a static set of components based on the visible size of the list. Anyway, you don’t have to worry about that unless you want a custom renderer… and then you can just look at DefaultCellRenderer’s source.
I think it’s pretty straight-forward:
https://code.google.com/p/jmonkeyplatform-contributions/source/browse/trunk/Lemur/extensions/LemurProto/src/main/java/com/simsilica/lemur/list/DefaultCellRenderer.java
There are probably some things yet missing from this implementation of ListBox (and its underlying GridPanel) because I haven’t used it “in anger” yet… but it’s functional and has all of the obvious parts. Please feel free to report issues or missing pieces you might find.