// contient les éléments de base
import javax.microedition.midlet.*;
// contient les éléments permettant de gérer l'interface
import javax.microedition.lcdui.*;
public class HelloWorld extends MIDlet implements CommandListener
{
private Display _display;
private TextField _textField1;
private TextField _textField2;
private Command _commandExit;
private Form _form1;
public HelloWorld()
{
// fait un lien avec l'affichage
_display = Display.getDisplay(this);
// creation d'un objet formulaire sur lequel on peut placer des composants
_form1 = new Form("test helloWorld");
// creation d'un bouton pour sortir du programme
_commandExit = new Command("Exit", Command.SCREEN,1);
// creation d'un champ de texte
_textField1 = new TextField("","date du jour",15,TextField.ANY);
_textField2 = new TextField("","Code du jour",15,TextField.ANY);
// ajout des composants au formulaire
_form1.addCommand(_commandExit);
_form1.append(_textField1);
_form1.append(_textField2);
_form1.setCommandListener(this);
}
// évènement exécuté au démarrage de l'application
public void startApp()
{
// affichage du formulaire
_display.setCurrent(_form1);
}
// évènement exécuté lors de la mise en pause de l'application
public void pauseApp()
{
}
// évènement exécuté lorsque l'application se termine
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c, Displayable s)
{
// lors du clic sur le bouton Exit
if (c == _commandExit)
{
// appel manuel à la fonction de fermeture
destroyApp(false);
// on demande au manager de fermer l'application
notifyDestroyed();
}
}
}
Partager