Help with j2me
From: Piotre Ugrumov (aumulone_at_tin.it)
Date: 08/29/04
- Next message: Real Gagnon: "Re: disabling maximize button of JFrame"
- Previous message: Balaji. M.: "Re-installing Java 1.5"
- Next in thread: Micah Clarke: "Re: Help with j2me"
- Reply: Micah Clarke: "Re: Help with j2me"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 29 Aug 2004 16:25:05 GMT
Hello I have a problem with j2me.
I have written this class(see later) that it run without problmes. But I
have a question. How can I add a command to a ChoiceGroup? I have add a
command to the form that contains the CoiceGroup, but how can I add a commad
directly to the ChoiceGroup?
Another question. I have a jar file with various classes. How can I import
these classes with the j2me wirless toolkit?
Thanks.
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class Secondo extends MIDlet implements CommandListener
{
private int a;
private Command exitCommand, cmrich, cmBack, sel, guid;
private String stanze[] = {"0=Ingresso", "1=StanzaA", "2=StanzaB",
"3=StanzaC",
"4=StanzaD", "5=StanzaE", "6=StanzaF", "7=StanzaG", "8=Uscita"};
private Display display;
private Form screen, scelta;
private TextField richiesto = new TextField("Percorso richiesto", "", 20,
TextField.ANY);
private TextBox guidato = new TextBox("Prova", "Inserisci dati", 25, 0);
private ChoiceGroup dove = new ChoiceGroup("Scegli", Choice.EXCLUSIVE,
stanze, null);
public Secondo()
{
display = Display.getDisplay(this);
exitCommand = new Command("Uscita", Command.EXIT, 1);
cmrich = new Command("Dove vuoi andare?", Command.SCREEN, 2);
cmBack = new Command("Indietro", Command.BACK, 1);
sel = new Command("Seleziona", Command.SCREEN, 2);
guid = new Command("Percorso guidato", Command.SCREEN, 2);
StringItem strItem = new StringItem(" ","Benvenuto!");
screen = new Form("Agente Cellulare");
screen.append(strItem);
screen.append(richiesto);
screen.addCommand(exitCommand);
screen.addCommand(cmrich);
screen.addCommand(guid);
screen.setCommandListener(this);
guidato.addCommand(cmBack);
guidato.setCommandListener(this);
scelta = new Form("Dove vuoi andare?");
scelta.append(dove);
scelta.addCommand(cmBack);
scelta.addCommand(sel);
scelta.setCommandListener(this);
}
public void startApp() throws MIDletStateChangeException
{
display.setCurrent(screen);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction (Command c, Displayable s)
{
if(c==exitCommand)
{
destroyApp(false);
notifyDestroyed();
}
else if(c==cmrich)
{
display.setCurrent(scelta);
}
else if(c==cmBack)
display.setCurrent(screen);
else if(c==sel)
{
a = dove.getSelectedIndex();
setRichiesto("Ecco: " + a);
display.setCurrent(screen);
}
else if(c==guid)
{
display.setCurrent(guidato);
}
}
public void setGuidato(String s)
{
guidato.setString(s);
}
public void setRichiesto(String s)
{
richiesto.setString(s);
}
}
- Next message: Real Gagnon: "Re: disabling maximize button of JFrame"
- Previous message: Balaji. M.: "Re-installing Java 1.5"
- Next in thread: Micah Clarke: "Re: Help with j2me"
- Reply: Micah Clarke: "Re: Help with j2me"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]