Mam problem z dodaniem ikon do pewnej listy. Widziałem to w przykładowych projektach, ale u mnie nie działa. Dostaję taki raport:
Project settings saved
Building "JavaOrganizer"
Build complete
Running with storage root C:\Users\Xet\j2mewtk\2.5.2\appdb\DefaultColorPhone
Running with locale: Polish_Poland.1250
Running in the identified_third_party security domain
Unable to create MIDlet JOMIDlet
java.lang.IllegalArgumentException
at javax.microedition.lcdui.ChoiceGroup.<init>(+129)
at javax.microedition.lcdui.List.<init>(+61)
at JOMIDlet.<init>(+32)
at java.lang.Class.runCustomCode(+0)
at com.sun.midp.midlet.MIDletState.createMIDlet(+34)
at com.sun.midp.midlet.Selector.run(+22)
Execution completed.
3462973 bytecodes executed
383 thread switches
1676 classes in the system (including system classes)
18510 dynamic objects allocated (561764 bytes)
8 garbage collections (481480 bytes collected)
Lista ma 9 pozycji, na pierwszych trzech ma być widoczna ikona "plus.png" ($PROJECT_DIR$/res/plus.png). Wszystkie ikonki są przechowywane w osobnej klasie IMAGES w zmiennych statycznych.
A oto kody klasy ikonek i użycia jej w liście:
/**
Images for lists
*/
class IMAGES
{
public static Image[] MAIN_MENU;
public static Image[] MANAGE = null;
public static Image[] PLAN = null;
public static Image[] HOMEWORK = null;
public static Image[] TEST = null;
public static Image[] GRADE = null;
public static Image[] EVENT = null;
public static Image[] PLAN_EDIT = null;
public static Image[] AHW_SUBJ_CG = null; // add_homework_subject_choice_group
public static Image[] HW_FORMS = null; // homework_forms
public static void createImages () {
try {
Image plus = Image.createImage("/plus.png");
MAIN_MENU = new Image[] { plus, plus, plus };
} catch ( Exception e ) {
System.out.println("exception: " + e.getMessage());
e.printStackTrace();
}
}
} /// endclass I`code>_________________________`// fragment JOMIDlet.JOMIDlet()
mainList = new List(LANG.MAIN_MENU, Choice.IMPLICIT, LISTS.MAIN_MENU, IMAGES.MAIN_MENU);
mainList.setSelectCommand( CMD_MAIN_SELECT );
mainList.addCommand( CMD_EXIT );
mainList.setCommandListener(new ListCommandListener());