IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Développement Mobile en Java Discussion :

comment passer d'une midlet à un formulaire à une alerte en J2ME


Sujet :

Développement Mobile en Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Inscrit en
    Février 2010
    Messages
    1
    Détails du profil
    Informations forums :
    Inscription : Février 2010
    Messages : 1
    Par défaut comment passer d'une midlet à un formulaire à une alerte en J2ME
    Bonjour,
    je suis en train de développer une application j2me sur mobile avec eclipse 3.4.0.
    j'ai un problème de passage à une alerte à partir d'un formulaire appelé à partir d'un midlet.En effet,l'alerte sollicitée suite à l'appel du bouton 'valider' du Form ne s'affiche pas .
    Pouvez vous m'aider.
    Voici le code:

    %%% MIDlet %%%

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    package Test;
     
    import javax.microedition.lcdui.Choice;
    import javax.microedition.lcdui.ChoiceGroup;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.midlet.*;
     
    public class Tache1 extends MIDlet implements CommandListener  {    
      private Display display;
      private Form form;
      private ChoiceGroup choiceGroup;
      Command cmd;
      private final static Command CMD_EXIT = new Command("Exit", Command.EXIT, 1);
      public Tache1() {
     
        display = Display.getDisplay(this);
        form = new Form("Operation désirée");
        choiceGroup = new ChoiceGroup("", Choice.EXCLUSIVE);
     
        choiceGroup.append("mise à jour",null);
        choiceGroup.append("recevoir statistiques", null);
        choiceGroup.setSelectedFlags(new boolean[] { false, false });
        form.append(choiceGroup);
     
        this.cmd = new Command("Suivant", Command.SCREEN, 0);
        form.addCommand(cmd);
     
        form.addCommand(CMD_EXIT);
        form.setCommandListener(this);
     
      }
     
     
     
      public void startApp() {
        display.setCurrent(form);
      }
     
      public void pauseApp() {
      }
     
      public void destroyApp(boolean unconditional) {
      }
     
    public void commandAction(Command c, Displayable d) {
    	if (c == this.cmd){
    		new update1(this);
    	}	
    }
    }
    %%% Form %%%

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    package Test;
     
    import javax.microedition.lcdui.Alert;
    import javax.microedition.lcdui.AlertType;
    import javax.microedition.lcdui.ChoiceGroup;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
     
    public class Update1 extends Form implements CommandListener{
      Tache1 t;
      private Display display;
      private Form form;
      private ChoiceGroup choiceGroup;
      Command cmd;
      private final static Command CMD_EXIT = new Command("Exit", Command.EXIT, 1);
      public Update1(Tache1 t) {
     
    	super ("Mise à jour");
    	this.t=t; 
    	form=new Form("Mise à jour");
    	Display.getDisplay(t).setCurrent(this.form); 
     
        choiceGroup = new ChoiceGroup("", ChoiceGroup.EXCLUSIVE);
        choiceGroup.append("formater", null);
        choiceGroup.append("modifier", null);
        choiceGroup.append("charger", null);
        choiceGroup.append("ajouter", null);
        choiceGroup.append("supprimer", null);
        choiceGroup.setSelectedFlags(new boolean[] { false, false, false, false,false });
        this.form.append(choiceGroup);
        this.cmd = new Command("valider", Command.SCREEN, 0);
        this.form.addCommand(this.cmd);
        this.form.addCommand(CMD_EXIT);
        this.form.setCommandListener(this);
     
     
     
      }
     
     
     
    public void commandAction(Command c, Displayable d) {
    	if (c == this.cmd) {
            String text = "  connexion NFC...";
            Alert a = new Alert("Please , wait", text, null, AlertType.INFO);
            this.display.setCurrent(a);
     
            }
    }
     
    }
    Merci beaucoup
    Meilleures Salutations

  2. #2
    Candidat au Club
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    4
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 4
    Par défaut
    C'est le "display" de la midlet auquel il faut passer l'instruction.
    Ta dernière ligne
    this.display.setCurrent(a);

    devrait donc être:
    t.display.setCurrent(a);

    Cdt

Discussions similaires

  1. Lancer une midlet A depuis une midlet B
    Par kamelcompte dans le forum Java ME
    Réponses: 1
    Dernier message: 18/11/2013, 14h28
  2. Réponses: 2
    Dernier message: 06/04/2007, 10h26
  3. passer des paramétres d'un formulaire à une requête
    Par lasmarmann dans le forum Access
    Réponses: 1
    Dernier message: 24/10/2006, 09h37
  4. copie d'une table Y d'une base A vers une table X d'une base
    Par moneyboss dans le forum PostgreSQL
    Réponses: 1
    Dernier message: 30/08/2005, 21h24

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo