1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| // contient les éléments de base
import java.io.IOException;
import javax.microedition.midlet.*;
// contient les éléments permettant de gérer l'interface
import javax.microedition.lcdui.*;
public class Affichage extends MIDlet implements CommandListener
{
private Display display;
private Image image;
private Command commandExit;
private Form form1;
public Affichage() throws IOException
{
// 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 de Image");
// creation d'un bouton pour sortir du programme
commandExit = new Command("Exit", Command.SCREEN,1);
// creation d'un champ de texte contenant notre Hello World
image = Image.createImage("/res/feu.gif");
// ajout des composants au formulaire
form1.addCommand(commandExit);
form1.append(image);
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