Image List in J2ME

package anuja;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.List;

public class ListImageMidlet extends MIDlet implements CommandListener {

private Display display;
private Command exitCmd, selectCmd;
private List listItems;
private Image blueStarImg, goldStarImg, redStarImg, yellowStarImg, golfImg;
private int index;

public void startApp() {

display = Display.getDisplay(this);

// First interface which is having items to select
listItems = new List(“List + Image”, List.IMPLICIT);

try {

blueStarImg = Image.createImage(“blue_star.png”);
goldStarImg = Image.createImage(“gold_star.png”);
redStarImg = Image.createImage(“red_star.png”);
yellowStarImg = Image.createImage(“yellow_star.png”);
golfImg = Image.createImage(“golf.png”);

} catch (IOException ex) {



listItems.append(“Blue Star”, blueStarImg);
listItems.append(“Gold Star”, goldStarImg);
listItems.append(“Red Star”, redStarImg);
listItems.append(“Yellow Star”, yellowStarImg);

exitCmd = new Command(“Exit”, Command.EXIT, 4);
selectCmd = new Command(“Select”, Command.OK, 5);



public void pauseApp() {

public void destroyApp(boolean unconditional) {

public void commandAction(Command c, Displayable d) {

index = listItems.getSelectedIndex();
if(c == exitCmd){


}else if(c == selectCmd || c == List.SELECT_COMMAND){

Alert alert = new Alert(“Selected”, “You have selected:” + listItems.getString(index) + “.”, null ,AlertType.INFO);
display.setCurrent(alert, listItems);




About AnujAroshA

Working as an Associate Technical Lead. Specialized in iOS application development. A simple person :)
This entry was posted in J2ME examples. Bookmark the permalink.

1 Response to Image List in J2ME

  1. RAKESH GUPTA says:

    hi anu
    i am working with an final year project in which i have to display various stops of best buses and required an textfield which help user to find an appropriate stop by entering an text in textfield
    for example :- if user type ‘a’ then the list should display all the stops which start with letter ‘a’
    please help me

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s