icons in form
hi..
i want to set a colllection of image in the form and when ever i choose one of the icon it link me to other class ,i have save this image in the array and then i used an item change listener in order to call every icon by it self but i get nothing ..please if you another way tell me
thank you
[318 byte] By [
java_csa] at [2007-11-26 15:55:16]

# 2
this is the code that i use
import java.util.Vector;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.*;
import javax.microedition.io.*;
import java.io.*;
public class IconsTester implements CommandListener, ItemStateListener {
private Display display;
private Form mainForm;
private ChoiceGroup optionsGroup;
private int itemNum;
private Command CMD_NEXT= new Command("Next", Command.ITEM,
2);
private Command CMD_BACK= new Command("Back", Command.BACK,
1);
private Image newApp = null;
private Image viewApp = null;
private Image cancelApp = null;
public IconsTester(Display d, Form backF)
{
display = d;
mainForm = new Form("Appointments");
mainForm.append("Choose an action to be performed: ");
Image[] imageArray = null;
try {
newApp = Image.createImage("/success.png");
viewApp = Image.createImage("/search.png");
cancelApp = Image.createImage("/time.png");
imageArray = new Image[] { newApp, viewApp, cancelApp };
}
catch (java.io.IOException err) {
System.out.println(err);
}
mainForm.append(new Spacer(40,40));
mainForm.append(newApp);
mainForm.append(new Spacer(40,40));
mainForm.append(viewApp);
mainForm.append(new Spacer(40,40));
mainForm.append(cancelApp);*/
mainForm.addCommand(CMD_BACK);
mainForm.addCommand(CMD_NEXT);
mainForm.setCommandListener(this);
mainForm.setItemStateListener(this);
display.setCurrent(mainForm);
}
public void commandAction(Command c, Displayable s) {
if (c == CMD_BACK) {
display.setCurrent(Login.list);
}
else
{
mainForm.setItemStateListener(this);
}
}
public void itemStateChanged(Item item)
{
if( item.equals(newApp))
{itemNum = 0;
new NewAppointment(display, mainForm);
}
else if( item.equals(viewApp))
{itemNum = 2;
new NewAppointment(display, mainForm);
}
else if( item.equals(cancelApp))
{itemNum = 1;
new NewAppointment(display, mainForm);
}
}
}