Witam
jestem początkującym programistom w programowaniu na telefony komórkowe
mój pierwszy program wygląda, że chce zrobić rozkład jazdy danego autobusu tylko, że pierwsze menu mam,
ale nie umie jeszcze zrobić pod menu do głównego menu brak mi pomysłów jestem bardzo początkującym programistom w programowaniu na komórkę
oto mój kod programu na bazie zmodyfikowanego przykładu:
import javax.microedition.midlet.;
import javax.microedition.lcdui.;
/**
- MIDlet ma zaprezentować obiekt List i formularz z
- różnymi typami ChoiceGroup.
*/
public class ListTryout
extends MIDlet implements CommandListener, ItemStateListener {
private Command exitCommand = new Command("Wyjście", Command.EXIT, 2);
private Command backCommand = new Command("Wróć", Command.BACK, 1);
private Display display;
private List list = new List("Menu", List.IMPLICIT);
private List Auchan = new List("Auchan", List.IMPLICIT);
private List tesco = new List("Tesco", List.IMPLICIT);
private Form form1 = new Form("Tesco");
private Form form2 = new Form ("Auchan");
private Form form3 = new Form("Kukuczki->Tesco");
private Form form31 = new Form("Kosmowskiej->Tesco");
private Form form32 = new Form("Starzyńskiego->Tesco");
private Form form33 = new Form("Michałowskiego->Tesco");
private Form form34 = new Form("Schillera->Tesco");
private Form form35 = new Form("PCK->Tesco");
private Form form36 = new Form("Politechnika->Tesco");
private Form form37 = new Form("Al.Jana_Pawła_II->Tesco");
private Form form38 = new Form("Tesco->Tesco");
private Form form4 = new Form ("O programie");
private ChoiceGroup chGroup1 =
new ChoiceGroup("Rozklad jazdy", ChoiceGroup.EXCLUSIVE);
private ChoiceGroup chGroup2 =
new ChoiceGroup("Rozklad jazdy", ChoiceGroup.MULTIPLE);
public ListTryout() {
display = Display.getDisplay(this);
//Definiuję wygląd listy (głównego menu)
list.setTicker(new Ticker("Rozkład Jazdy Tesco, Auchan"));
list.append("Tesco", null);
list.append("Auchan", null);
list.append("Kukuczki->Tesco", null);
list.append("Kosmowskiej->Tesco", null);
list.append("Starzyńskiego->Tesco", null);
list.append("Michałowskiego->Tesco", null);
list.append("Schillera->Tesco", null);
list.append("PCK->Tesco", null);
list.append("Politechnika->Tesco", null);
list.append("Al.Jana_Pawła_II->Tesco", null);
list.append("Tesco->Tesco", null);
list.append("O_programie", null);
list.addCommand(exitCommand);
list.setCommandListener(this);
//Definiuję wygląd listy (głównego menu)
// tesco.setTicker(new Ticker("Kukuczki->Tesco"));
form3.append("11| 00 \n");
form3.append("12| 00 \n");
form3.append("13| 00 \n");
form3.append("14| - \n");
form3.append("15| 00 \n");
form3.append("16| 00 \n");
form3.append("17| 00 \n");
form3.append("18| 00 \n");
form3.append("19| 00 \n");
form3.append("20| - \n");
form3.append("21| 00 \n");
form3.addCommand(backCommand);
form3.setCommandListener(this);
//Definiuję wygląd listy (głównego menu)
// tesco.setTicker(new Ticker("Kosmowskiej->Tesco"));
form3.append("11| 02 \n");
form31.append("12| 02 \n");
form31.append("13| 00 \n");
form31.append("14| - \n");
form31.append("15| 02 \n");
form31.append("16| 02 \n");
form31.append("17| 02 \n");
form31.append("18| 02 \n");
form31.append("19| 02 \n");
form31.append("20| - \n");
form31.append("21| 02 \n");
form31.addCommand(backCommand);
form31.setCommandListener(this);
//Definiuję wygląd listy (głównego menu)
// tesco.setTicker(new Ticker("Starzyńskiego->Tesco"));
form32.append("11| 03 \n");
form32.append("12| 03 \n");
form32.append("13| 03 \n");
form32.append("14| - \n");
form32.append("15| 03 \n");
form32.append("16| 03 \n");
form32.append("17| 03 \n");
form32.append("18| 03 \n");
form32.append("19| 03 \n");
form32.append("20| - \n");
form32.append("21| 03 \n");
form32.addCommand(backCommand);
form32.setCommandListener(this);
//Definiuję wygląd listy (głównego menu)
// tesco.setTicker(new Ticker("Michałowskiego->Tesco"));
form33.append("11| 04 \n");
form33.append("12| 04 \n");
form33.append("13| 04 \n");
form33.append("14| - \n");
form33.append("15| 04 \n");
form33.append("16| 04 \n");
form33.append("17| 04 \n");
form33.append("18| 04 \n");
form33.append("19| 04 \n");
form33.append("20| - \n");
form33.append("21| 04 \n");
form33.addCommand(backCommand);
form33.setCommandListener(this);
//Definiuję wygląd listy (głównego menu)
// tesco.setTicker(new Ticker("Schillera->Tesco"));
form34.append("11| 05 \n");
form34.append("12| 05 \n");
form34.append("13| 05 \n");
form34.append("14| - \n");
form34.append("15| 05 \n");
form34.append("16| 05 \n");
form34.append("17| 05 \n");
form34.append("18| 05 \n");
form34.append("19| 05 \n");
form34.append("20| - \n");
form34.append("21| 05 \n");
form34.addCommand(backCommand);
form34.setCommandListener(this);
//Definiuję wygląd listy (głównego menu)
// tesco.setTicker(new Ticker("PCK->Tesco"));
form35.append("11| 09 \n");
form35.append("12| 09 \n");
form35.append("13| 09 \n");
form35.append("14| - \n");
form35.append("15| 09 \n");
form35.append("16| 09 \n");
form35.append("17| 09 \n");
form35.append("18| 09 \n");
form35.append("19| 09 \n");
form35.append("20| - \n");
form35.append("21| 09 \n");
form35.addCommand(backCommand);
form35.setCommandListener(this);
//Definiuję wygląd listy (głównego menu)
// tesco.setTicker(new Ticker("Politechnika->Tesco"));
form36.append("11| 12 \n");
form36.append("12| 12 \n");
form36.append("13| 12 \n");
form36.append("14| - \n");
form36.append("15| 12 \n");
form36.append("16| 12 \n");
form36.append("17| 12 \n");
form36.append("18| 12 \n");
form36.append("19| 12 \n");
form36.append("20| - \n");
form36.append("21| 12 \n");
form36.addCommand(backCommand);
form36.setCommandListener(this);
//Definiuję wygląd listy (głównego menu)
// tesco.setTicker(new Ticker("Al.Jana_Pawła_II->Tesco"));
form37.append("11| 14 \n");
form37.append("12| 14 \n");
form37.append("13| 14 \n");
form37.append("14| - \n");
form37.append("15| 14 \n");
form37.append("16| 14 \n");
form37.append("17| 14 \n");
form37.append("18| 14 \n");
form37.append("19| 14 \n");
form37.append("20| - \n");
form37.append("21| 14 \n");
form37.addCommand(backCommand);
form37.setCommandListener(this);
//Definiuję wygląd listy (głównego menu)
// tesco.setTicker(new Ticker("Tesco->Tesco"));
form38.append("11| 20 \n");
form38.append("12| 20 \n");
form38.append("13| 20 \n");
form38.append("14| - \n");
form38.append("15| 20 \n");
form38.append("16| 20 \n");
form38.append("17| 20 \n");
form38.append("18| 20 \n");
form38.append("19| 20 \n");
form38.append("20| - \n");
form38.append("21| 20 \n");
form38.addCommand(backCommand);
form38.setCommandListener(this);
//Definiuję wygląd listy (głównego menu)
Auchan.setTicker(new Ticker("Wybierz rodzaj ChoiceGroup..."));
Auchan.append("Auchan...", null);
Auchan.append("...Auchan", null);
form4.addCommand(backCommand);
form4.setCommandListener(this);
//Definiuję wygląd pierwszego formularza z ChoiceGroup typu EXCLUSIVE
chGroup1.append("opcja 1",null);
chGroup1.append("opcja 2",null);
chGroup1.append("opcja 3",null);
chGroup1.append("opcja 4",null);
form1.append(chGroup1);
form1.addCommand(backCommand);
form1.setCommandListener(this);
form1.setItemStateListener(this);
//Definiuję wygląd pierwszego formularza z ChoiceGroup typu EXCLUSIVE
chGroup2.append("opcja 1",null);
chGroup2.append("opcja 2",null);
chGroup2.append("opcja 3",null);
chGroup2.append("opcja 4",null);
form2.append(chGroup2);
form2.addCommand(backCommand);
form2.setCommandListener(this);
form2.setItemStateListener(this);
}
public void startApp() {
display.setCurrent(list);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
/** Obserwator pozwalający reagować na akcje związane z komendami.
*/
public void commandAction(Command c, Displayable s) {
if (c == List.SELECT_COMMAND) {
if (list.getString(list.getSelectedIndex()) == "Tesco") {
display.setCurrent(form1);
}
else if (list.getString(list.getSelectedIndex()) == "Auchan") {
display.setCurrent(form2);
}
else if (list.getString(list.getSelectedIndex()) == "Kukuczki->Tesco") {
display.setCurrent(form3);
}
else if (list.getString(list.getSelectedIndex()) == "Kosmowskiej->Tesco") {
display.setCurrent(form31);
}
else if (list.getString(list.getSelectedIndex()) == "Starzyńskiego->Tesco") {
display.setCurrent(form32);
}
else if (list.getString(list.getSelectedIndex()) == "Michałowskiego->Tesco") {
display.setCurrent(form33);
}
else if (list.getString(list.getSelectedIndex()) == "Schillera->Tesco") {
display.setCurrent(form34);
}
else if (list.getString(list.getSelectedIndex()) == "PCK->Tesco") {
display.setCurrent(form35);
}
else if (list.getString(list.getSelectedIndex()) == "Politechnika->Tesco") {
display.setCurrent(form36);
}
else if (list.getString(list.getSelectedIndex()) == "Al.Jana_Pawła_II->Tesco") {
display.setCurrent(form37);
}
else if (list.getString(list.getSelectedIndex()) == "Tesco->Tesco") {
display.setCurrent(form38);
}
else if (list.getString(list.getSelectedIndex()) == "O_programie") {
display.setCurrent(form4);
}
}
else if (c == backCommand) {
display.setCurrent(list);
}
else if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
/** Obserwator zmian w stanie obiektów elementu Form.
- Możemy tutaj reagować na zmiany ich stanu.
*/
public void itemStateChanged(Item item) {
if ((ChoiceGroup)item == chGroup1)
System.out.println("Zmieniono ChoiceGroup typu Tesco.");
if ((ChoiceGroup)item == chGroup2)
System.out.println("Zmieniono ChoiceGroup typu Auchan.");
System.out.println("Stan elementów:");
for (int i=0;i<((ChoiceGroup)item).size();i++)
System.out.println("opcja " + (i+1) + ": "
- ((ChoiceGroup)item).isSelected(i));
}
}
plik ListTryout.jad
MIDlet-1: ListTryout, ListTryout.png, ListTryout
MIDlet-Jar-Size: 100
MIDlet-Jar-URL: ListTryout.jar
MIDlet-Name: ListTryout
MIDlet-Vendor: Unknown
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.1
plik MANIFEST.MF
MIDlet-1: ListTryout, ListTryout.png, ListTryout
MIDlet-Name: ListTryout
MIDlet-Vendor: Unknown
MIDlet-Version: 1.0
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.1
program J2ME Wireless Toolkit kompiluje mój zmodyfikowany program który teraz przedstawiłem, ale nie tworzy mi pliku jar
jak nacisnę dwa razy na plik ListTryout.jad
wyskakuje komunikat
"com sun kvem midletsuite invalidJadException: Reason = 36
error in opening jar file: ListTryout.jar"
bardzo proszę o jakieś wskazówki jak zrobić pod menu żeby zrobić np: 1 menu rozkaład a podmenu ...-tesco, tesco-..., następne pod menu przytanki itd
może coś źle robię pierwszy raz to robię może ktoś by pomógł był bym bardzo wdzięczny.
moje gg 25888159
z góry dziękuje za odpowiedz