Introducing a Lightweight UI Toolkit: Shake Your User Interface

It is very important that you set the containing form as non-scrollable: List implements its own scroll and your application will behave strangely if you don't do so.

In your application, you pass a Vector of YWRecords to the List, but how is it going to be rendered a YWRecord? They aren't LWUIT components, so you have to tell to the List how to show them. You defined a LocationRenderer class that implements ListInterface:

getListCellRendererComponent: Receives all values passed to the List, and returns a LWUIT component that displays information as you want. And when you say "component," you are also referring to Containers, so you can see that a List can be composed of complex components.

getListFocusComponent: Returns a component that is going to be used to paint the pointer or the current focused component. You can think of it as it was a magnifying glass that you move up or down above the List: It must have some degree of transparency to see what is under it when the focus on the List moves. Once the focused item reaches the cell location, this Component is drawn under the selected item. It can be null, but defining it in your List in conjunction with setting smooth scrolling brings you a cool effect.

In LwuitWeather, you have implemented a common paradigm on LWUIT: You create a component that also implements the ListCellRenderer interface, so it can be returned from those methods. This way, you avoid creating a new Component each time getListCellRendererComponent is called. Remember that we are developing to devices with big memory constraints.

Notice that getListCellRendererComponent also receives all the List as a parameter: With a little coding, it will be easy to create a List that focuses elements and alters the appearance of near components, like in a Fish Eye Menu. I will let that be an exercise for readers to implement it.

Finally, you should react to selections of items on that list. To achieve that, PlacesDisplay will be your actionListener, whose action performing method is shown next: