J2ME and LWUIT – Java Mobile Programming Cell

This post is a continuation of the last class for the Java mobile application programming cell organized by SCOSIT. The assumption is that you have done the first part but I will still provide the code sample for the first part.
An Overview of the Application
We were developing an application that allows a person to check the food that is available at the student mess. At the end of the tutorial you should have an application shown in the screen shots below

Meal selection menu

Meal selection menu

List of available food

List of available food












We had done the first part of the application whereby we were able to select the meal we are inquiring about. You can download the original-code
Creating the List of Foods
We are now going to work on showing the list of food available for the selection we have made. The steps are as follows
1.    Create a java class FoodList. This class is going to hold all the food that we have. The class has the following class variables
•    Strings – name,details,price
•    Image – icon
It has an empty constructor and another parameterized constructor to initialize the above variables. The class also has the setters and getters for all of our variables. You can download the class FoodList.
2.    Create another class ListFoodCellRenderer. This class is used to style the list. Download the class FoddListCellRenderer and go through it keenly. We are extending the existing LWUIT ListCellRender and modifying how it works.
3.    Go back to your midlet and create a method showFoodList. This method will be used to display the list of foods and it will use the FoodList and ListFoodCellRenderer classes. The method signature is as follows
public void showFoodList(){
Please download the method code showFoodList and follow it step by step. I have tried to comment everything I have done and so it should be easy enough to understand it.
4.    In the actionPerformed method when the breakfast button is clicked invoke the showFoodList method

I am working on having the project on Git, will provide the link as soon as I do so. If you have any question please feel free to ask.

7 thoughts on “J2ME and LWUIT – Java Mobile Programming Cell

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s